JavaScript Operators

Operator -
operator are symbol that exist in every programming language . and it is used to perform operation on the operen, called as operator.
let's understand meaning of operent, operator, operation.
a = 5 // 5 is operent
b = 6 // 6 is operent
c = a + b // + symbol is operent
whole process is called operation.
In javascript so many operator exist but there are mainly 5 operator exist. let's discuss one by one in depth and details.
Arthimetic operator
Assignment opertor
Comparison operator
logical operator
Bitwise operator
1. Arithemetic operator :-
Arithmetic is basic and fundamental operator of javascript that used to perform arithemetic operation.
let's discuss all arithmetic operator through table.
| Operator Name | Operator Symbol | Example |
|---|---|---|
| Addition | + | 5 + 5 = 10 |
| Subtraction | - | 10 - 5 = 5 |
| Multiplication | * | 3 * 5 = 15 |
| Division | / | 10 / 2 = 5 |
| Modules | % | 5 % 3 = 2 |
| Exponential | ** | 2 ** 3 = 8 |
| Increment | ++ | 5++, ++5 |
| Decrement | -- | 6--, --6 |
2.Assignment operator -
Assignment opertor is used to perform Assignment operation or used to assign the value.
| Symbol | Example |
|---|---|
| = | a = 5 |
| += | a += 5 |
| -= | a -= 6 |
| *= | a *= 6 |
| /= | b /= 10 |
| %= | c %= 4 |
3.Comparision Operator -
It is used to compare the value between two operent, and result is always either True or False.
| Name | Symbol | Example | Result |
|---|---|---|---|
| Less than | < | 5 < 3 | False |
| Less than or equal to | <= | 5 <= 6 | True |
| Greater than | > | 7 > 6 | True |
| Greater than or equal to | >= | 6 >= 10 | False |
| Equal to | == | 5 == "5" | True |
| Strictly equal to | === | True === True | True |
| Not equal to | != | "" != 0 | False |
| Strictly not equal to | !== | 5 !== 5 | False |
"" Empty string value is false
"4" non-empty string value is true
0 - Zero consider as false
4 - Non- zero consider as true
null - consider as false
undefined - consider as false
4.Logical operator -
Logical operator is widely used operator for the perform logical operation like and, or and not, it is used to check multiple condition.
| Name | Symbol | Example | Result |
|---|---|---|---|
| Logical and | && | True && "5" | "5" |
| Logical or | |||
| Logical not | ! | !True | False |
5.Bitwise operator -
Bitwise operator is not widely used , but very useful when work with bit or bit manupulation, also very useful for the performance.
| Name | Symbol | Example |
|---|---|---|
| Bitwise and | & | 5 & 7 |
| Bitwise or | ||
| Bitwise xor | ^ | 4 ^ 2 |
| Not | ~ | ~5 |
| Left shift | << | 5 << 2 |
| Right shift | >> | 5 >> 2 |
Conclusion
Operators are the building blocks for performing calculations, comparisons, assignments and logical or bitwise manipulations in JavaScript
In this article we covered the five main groups—arithmetic, assignment, comparison, logical, and bitwise—and reviewed the common symbols and examples for each. Understanding how each operator behaves (including special cases like % with negative numbers, and the difference between pre- and post-increment/decrement) is essential for writing correct, predictable code.
Quick practice Tips -
Prefer
===and!==to avoid unexpected type coercion with==and!=.Remember operator precedence and use parentheses to make intentions clear.
Know that logical operators (
&&,||) short-circuit and can be used for concise conditional expressions.Use compound assignment (e.g.,
+=,*=) for shorter, clearer updates.Use bitwise operators only when you need low-level integer manipulation; they operate on 32-bit integers.




