The JavaScript Bitwise operators consider the operands as a sequence of 32 bits. The following bitwise operators are available in JavaScript −
| Sr.No. | Operator & Operator Name |
|---|---|
| 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 |
Let’s see an example of JavaScript Bitwise OR(|) operator.
Example
If one of the bits are 1, then 1 is returned when Bitwise OR (|) operator is used. You can try to run the following code to learn how to work with JavaScript Bitwise OR Operator −
<!DOCTYPE html>
<html>
<body>
<script>
document.write("Bitwise OR Operator<br>");
// 7 = 00000000000000000000000000000111
// 1 = 00000000000000000000000000000001
document.write(7 | 1);
</script>
</body>
</html>