JavaScript Operators
JavaScript Operators
- Arithmetic Operators
- Comparison (Relational) Operators
- Logical Operators
- Bitwise Operators
- Assignment Operators
|
Operator |
Description |
|
+ |
Addition |
|
- |
Subtraction |
|
* |
Multiplication |
|
** |
Exponentiation
|
|
/ |
Division |
|
% |
Modulus
(Division Remainder) |
|
++ |
Increment |
|
-- |
Decrement |
|
Operator |
Description |
|
== |
equal to |
|
=== |
equal value and equal type |
|
!= |
not equal |
|
!== |
not equal value or not equal type |
|
> |
greater than |
|
< |
less than |
|
>= |
greater
than or equal to |
|
<= |
less than or equal to |
|
? |
ternary operator |
|
Operator |
Description |
|
+ |
Addition |
|
- |
Subtraction |
|
* |
Multiplication |
|
** |
Exponentiation
|
|
/ |
Division |
|
% |
Modulus
(Division Remainder) |
|
++ |
Increment |
|
-- |
Decrement |
|
Operator |
Description |
|
&& |
logical and |
|
|| |
logical
or |
|
! |
logical not |
|
Operator |
Description |
Example |
Same as |
Result |
Decimal |
|
& |
AND |
5 & 1 |
0101 & 0001 |
0001 |
1 |
|
| |
OR |
5 | 1 |
0101 |
0001 |
0101 |
5 |
|
~ |
NOT |
~ 5 |
~0101 |
1010 |
10 |
|
^ |
XOR |
5 ^ 1 |
0101 ^
0001 |
0100 |
4 |
|
<< |
Zero fill left shift |
5 << 1 |
0101 << 1 |
1010 |
10 |
|
>> |
Signed
right shift |
5
>> 1 |
0101
>> 1 |
0010 |
2 |
|
>>> |
Zero fill right shift |
5 >>> 1 |
0101 >>> 1 |
0010 |
2 |
|
Operator |
Example |
Same As |
|
= |
x = y |
x = y |
|
+= |
x += y |
x = x + y |
|
-= |
x -= y |
x = x - y |
|
*= |
x *= y |
x = x * y |
|
/= |
x /= y |
x = x / y |
|
%= |
x %= y |
x = x % y |
|
**= |
x **= y |
x = x ** y |

0 comments
Please leave your comments...... Thanks