Bitwise AND
& is the bitwise AND operator. The bitwise AND lines up the bits in each number and do the AND operation.
The AND operation between the two bits is: The result will be 1 only if both bits are 1. If either bit is 0, then the result is 0.
Operand 1 | Operand 2 | RESULT |
---|---|---|
1 | 1 | 1 |
1 | 0 | 0 |
0 | 1 | 0 |
0 | 0 | 0 |
<!DOCTYPE html>
<html>
<head>
<title>Operator Example</title>
<script type="text/javascript">
var result = 4 & 3;
document.writeln(result); //0
</script>
</head>
<body>
</body>
</html>
Home
JavaScript Book
Language Basics
JavaScript Book
Language Basics
Operators:
- JavaScript Operators
- Increment/Decrement Operators
- Increment/Decrement Operators for String, Boolean, Floating-point and Object
- Unary Plus and Minus
- Bitwise Not operator
- Bitwise AND
- Bitwise OR
- Bitwise XOR
- Left Shift
- Signed Right Shift
- Unsigned Right Shift
- Logical NOT
- Logical AND
- Logical OR
- Multiply
- Divide
- Modulus
- Add
- Subtract
- Relational Operators
- Equal and Not Equal
- Identically Equal and Not Identically Equal
- Conditional Operator
- Assignment Operators
- Comma Operator