Like C, C++, Java, Python and various other languages, JavaScript also supports bitwise operations. In JavaScript, a number is stored as a 64bit floating point number but the bitwise operation is performed on a 32bit binary number i.e. to perform a bitoperation JavaScript converts the number into a 32bit binary number (signed) and perform the operation and convert back the result to a 64bit number.
Below are few bitwise logical operators used in JavaScript.
A  B  OUTPUT ( A & B ) 

0  0  0 
0  1  0 
1  0  0 
1  1  1 
A  B  OUTPUT ( A  B ) 

0  0  0 
0  1  1 
1  0  1 
1  1  1 
A  B  OUTPUT ( A ^ B ) 

0  0  0 
0  1  1 
1  0  1 
1  1  0 
A  OUTPUT ( ~A ) 

0  1 
1  0 
Below are few bitwise shift operators used in JavaScript.

Left Shift ( << ): Its a binary operator i.e. it accepts two operand. The first operator specifies the number and the second operator specifies the number of bits to shift. Each bits are shifted towards left and 0 bits are added from the right. The excess bits from the left are discarded.
A 6 ( 00000000000000000000000000000110 ) B 1 ( 00000000000000000000000000000001 ) OUTPUT ( A 12 ( 00000000000000000000000000001100 )  Sign Propagating Right Shift ( >> ) : Its a binary operator i.e. it accepts two operand. The first operand specifies the number and the second operand specifies the number of bits to shift. Each bit is shifted towards the right, the overflowing bits are discarded. This is Sign Propagating as the bits which are added from the left depends upon the sign of the number (i.e. 0 if positive and 1 if negative )
A 6 ( 00000000000000000000000000000110 ) B 1 ( 00000000000000000000000000000001 ) OUTPUT ( A >> B ) 3 ( 00000000000000000000000000000011 ) 
Zero fill Right Shift ( >>> ) : Its a binary operator i.e. it accepts two operand. The first operand specifies the number and the second operand specifies the number of bits to shift. Each bits is shifted towards right, the overflowing bits are discarded. 0 bit is added from the left so its zero fill right shift.
A 6 ( 00000000000000000000000000000110 ) B 1 ( 00000000000000000000000000000001 ) OUTPUT ( A >>> B ) 3 ( 00000000000000000000000000000011 ) Below is the implementation of the above described operators.
<script>
var
a = 6;
var
b = 1;
// AND Operation
document.write(
"A & B = "
+ (a & b) +
'<br>'
);
// OR operation
document.write(
"A  B = "
+ (a  b) +
'<br>'
);
// NOT operation
document.write(
"~A = "
+ (~a) +
'<br>'
);
// Sign Propagating Right Shift
document.write(
"A >> B = "
+ (a >> b) +
'<br>'
);
// Zero Fill Right Shift
document.write(
"A >>> B = "
+ (a >>> b) +
'<br>'
);
// Left Shift
document.write(
"A << B = "
+ (a << b) +
'<br>'
);
</script>
chevron_rightfilter_noneOutput:
A & B = 0 A  B = 7 ~A = 7 A >> B = 3 A >>> B = 3 A
Recommended Posts:
 JavaScript Course  Logical Operators in JavaScript
 JavaScript  Operators
 JavaScript  Arithmetic Operators
 JavaScript  Comparison operators
 JavaScript  Assignment operators
 JavaScript Course  Operators in JavaScript
 ES6  Operators
 Introduction to JavaScript Course  Learn how to Build a task tracker using JavaScript
 How to compare two JavaScript array objects using jQuery/JavaScript ?
 JavaScript Course  Understanding Code Structure in JavaScript
 JavaScript Course  Conditional Operator in JavaScript
 JavaScript Course  Data Types in JavaScript
 JavaScript Course  Printing Hello World in JavaScript
 JavaScript Course  Loops in JavaScript
 JavaScript Course  JavaScript Prompt Example
 JavaScript Course  Variables in JavaScript
 JavaScript Course  Functions in JavaScript
 JavaScript Course  Objects in JavaScript
 JavaScript vs Python : Can Python Overtop JavaScript by 2020?
 How to include a JavaScript file in another JavaScript file ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.