Bitwise XOR
The bitwise XOR operator is ^. Here is the truth table for bitwise XOR:
Operand 1 | Operand 2 | Result |
---|---|---|
1 | 1 | 0 |
1 | 0 | 1 |
0 | 1 | 1 |
0 | 0 | 0 |
Bitwise XOR returns 1 only when one operand has a value of 1. If both bits contain 1, it returns 0.
<!DOCTYPE html>
<html>
<head>
<title>Example</title>
<script type="text/javascript">
var result = 5 ^ 3;
document.writeln(result); //6
</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