What ~ does, and is is safe to use?

This question already has an answer here:

  • How does !!~ (not not tilde/bang bang tilde) alter the result of a 'contains/included' Array method call? 13 answers
  • What does a tilde do when it precedes an expression? 6 answers

  • Bitwise Operators

    ~a

    Performs the NOT operator on each bit.

    Example:

    9 (base 10) = 00000000000000000000000000001001 (base 2)

    ~9 (base 10) = 11111111111111111111111111110110 (base 2) = -10 (base 10)

    链接地址: http://www.djcxy.com/p/74964.html

    上一篇: JQuery:这个代码是什么意思?

    下一篇: 什么〜做,并且是安全使用?