Javascript Reference
Categories: Operators

javascript Operators ~

@March 15, 2008, 1:22 a.m.
~ Firefox/Netscape/NN 2 IE 3 ECMA 1  

  

This is the bitwise NOT operator. This unary operator inverts the value of the binary digit in each column of a number. For example, the binary 6 is 0110 (with many more zeros off to the left). After the negation operation on each column's value, the binary result is 1001, plus all zeros to the left inverted to 1s. The decimal equivalent is a negative value (-5).

 
Example
 
var n = ~6;

Powered by Linode.