Name

~ — NN 2 IE J1 ECMA 1

Synopsis

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

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.