
Working with JavaScript bitwise operators is an advanced topic and requires that you have basic knowledge of bits and bytes.
Bitwise operators in Javascipt are provided for playing with numbers at the lowest level of bits. The operands to the bitwise operators are treated as a set of 32 bits, each bit having a value 0 or 1.
For instance we can write the decimal number ten as a set of 32 bits as under:
00000000000000000000000000001010
It is important to note that although bitwise operators perform their operations at the level of bits, they return standard Java Script numerical values.
The following table lists different bitwise operators available in JavaScript:
Operator Name 
syntax 
Description 
Bitwise AND 
a & b 
Returns a one in each bit position for which the corresponding bits of both operands are ones. 
Bitwise OR 
a  b 
Returns a one in each bit position for which the corresponding bits of either or both operands are ones. 
Bitwise XOR 
a ^ b 
Returns a one in each bit position for which the corresponding bits of either but not both operands are ones. 
Bitwise NOT 
~ a 
Inverts the bits of its operand i.e. changes all zeros to ones and all ones to zeros. 
Left shift 
a << b 
Shifts a in binary representation b bits to left, shifting in zeros from the right. 
Signpropagating right shift 
a >> b 
Shifts a in binary representation b bits to right, propagating the sign, discarding bits shifted off. 
Zerofill right shift 
a >>> b 
Shifts a in binary representation b bits to the right, discarding bits shifted off, and shifting in zeros from the left. 

