JavaScript Bitwise Operators
The bitwise operator in JavaScript is used to convert the number to a 32-bit binary number and perform the bitwise operation. The number is converted back to the 64-bit number after the result.
Name |
Description |
Syntax |
Example |
The operator returns true only if both the operands are true |
A = 6, B=1 A&B = 0 |
||
The operator returns true even if one of the operands is true |
A = 6, B=1 A|B = 7 |
||
The operator returns true if both operators are distinct |
A = 6, B=1 A^B = 7 |
||
This operator is used to invert the boolean value of the operand |
A = 6 ~A = -7 |
||
In this two operators are used where the first operand is the number and the second operand is the number of bits to shift to the left. |
A = 6, B=1 A<<B = 12 |
||
In this two operators are used where the first operand is the number and the second operand is the number of bits to shift to the right. |
A = 6, B=1 A>>B = 3 |
||
It is same as a bitwise right shift the only difference is that overflowing bits are discarded. |
A = 6, B=1 A>>>B = 3 |
JavaScript Operators
JavaScript operators are symbols used to perform specific mathematical, comparison, assignment, and logical computations on operands. They are fundamental elements in JavaScript programming, allowing developers to manipulate data and control program flow efficiently. Understanding the different types of operators and how they work is important for writing effective and optimized JavaScript code.
JavaScript Operators: There are various operators supported by JavaScript.
Table of Content
- JavaScript Arithmetic Operators
- JavaScript Assignment Operators
- JavaScript Comparison Operators
- JavaScript Logical Operators
- JavaScript Bitwise Operators
- JavaScript Ternary Operators
- JavaScript Comma Operators
- JavaScript Unary Operators
- JavaScript Relational Operators
- JavaScript BigInt Operators
- JavaScript String Operators