Bitwise OR

The bitwise OR operator is |. It works on two numbers.

Bitwise OR follows the rules in this truth table:

Operand 1Operand 2Result
111
101
011
000

A bitwise OR operation returns 1 if at least one operand is 1. It returns 0 only if both operands are 0.

 
<!DOCTYPE html>
<html>
<head>
    <title>Example</title>
    <script type="text/javascript">
    
        var result = 2 | 3; 
        document.writeln(result); // 3

       
    </script>
</head>
<body>
</body>
</html>
  
Click to view the demo
Home 
  JavaScript Book 
    Language Basics  

Operators:
  1. JavaScript Operators
  2. Increment/Decrement Operators
  3. Increment/Decrement Operators for String, Boolean, Floating-point and Object
  4. Unary Plus and Minus
  5. Bitwise Not operator
  6. Bitwise AND
  7. Bitwise OR
  8. Bitwise XOR
  9. Left Shift
  10. Signed Right Shift
  11. Unsigned Right Shift
  12. Logical NOT
  13. Logical AND
  14. Logical OR
  15. Multiply
  16. Divide
  17. Modulus
  18. Add
  19. Subtract
  20. Relational Operators
  21. Equal and Not Equal
  22. Identically Equal and Not Identically Equal
  23. Conditional Operator
  24. Assignment Operators
  25. Comma Operator