JS ⟩ statement ⟩ expression ⟩ operator ⟩ arithmetic ⟩ bitwise
bitwise and (&), or (|), xor (^), not (~)
shift left (<<), right (>>), right with 0 fill (>>>)
~x // invert bits (convert to number, = -x - 1)
these operators convert their operand to 32-bit integers❗
🌟 table of operators
bitwise operators
➕ bitwise and (&) / or (|) / xor (^) / bitwise not (~)
➕ shift left (<<) / right (>>) / right with 0 fill (>>>)
related topics
💡 2's complement (-x = ~x + 1)
-x = ~x + 1
🔰 double tilde (~~) - nearest integer towards 0.
tools
💾 bitview() - 32-bit representation of signed integers.
bitwise operator
NaN, ±Infinity all converts to 0❗
all (except >>>) can be used with Number / BigInt.
bitwise operators convert their operands to 32-bit integers❗
JavaScript: The Definitive Guide ⟩ 4.8.3 Bitwise Operators
Last updated 3 years ago