# JavaScript Bitwise Operators

You are Here:

## JavaScript Bitwise Operators

The `bitwise operators` work by converting values (num1 and num2) to 32-bit binary numbers and then comparing the individual bits of these two binary numbers. The result is returned as a normal decimal number.

For example, the decimal number 52 has a binary representation of 110100. Please check our decimal to binary Online converter for reference.

## AND Operator

### Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 4; var num2 = 1; document.write(num1 & num2); </script> </body> </html>

## JavaScript Bitwise Operators

OperatorExplanationOperationResult
&AND4 & 10
|OR4 | 15
^XOR4 ^ 15
~NOT~4-5
<<Zero fill left shift4 << 18
>>Signed right shift4 >> 12
>>>Zero fill right shift4 >>> 12

## OR Operator

### Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 4; var num2 = 1; document.write(num1 | num2); </script> </body> </html>

## XOR Operator

### Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 4; var num2 = 1; document.write(num1 ^ num2); </script> </body> </html>

## NOT Operator

### Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num = 4; document.write(~num); </script> </body> </html>

## Zero Fill Left Shift Operator

### Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 4; var num2 = 1; document.write(num1 << num2); </script> </body> </html>

## Signed Right Shift Operator

### Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 4; var num2 = 1; document.write(num1 >> num2); </script> </body> </html>

## Zero Fill Right Shift Operator

### Example

HTML Online Editor
<!DOCTYPE html> <html> <body> <script> var num1 = 4; var num2 = 1; document.write(num1 >>> num2); </script> </body> </html>

## Reminder

Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.