JavaScript Bit-wise Operators

Like other programming languages JavaScript also supports bitwise operators. JavaScript, a number is stored as a 64-bit floating-point number but the bit-wise operation is performed on a 32-bit binary number.

JavaScript Bitwise Operators

The JavaScript Bitwise operators consider the operands as a sequence of 32 bits. Here is a table of bitwise operators with name and description.

Sr.No. Name and Description
1 &
Bitwise AND
2 |
Bitwise OR
3 ^
Bitwise XOR
4 ~
Bitwise NOT
5 <<
Bitwise Zero fill left shift
6 >>
Bitwise Signed right shift
7 >>>
Bitwise Zero-fill right shift

Example of bitwise opertators

Following is the code for bitwise operator in JavaScript −

<script>
   document.write("Bitwise OR Operator<br>");
         // 7 = 00000000000000000000000000000111
         // 1 = 00000000000000000000000000000001
         document.write(7 | 1);
</script>                  
        







The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.