An operator provides a result by performing an action on a single or more operands .
Arithmetic Operators
Operator | Description | Example |
---|
+ | Addition | 100 + 50 = 150 |
- | Subtraction | 100 - 50 = 50 |
* | Multiplication | 100 * 50 = 5000 |
/ | Division | 100 / 50 = 2 |
% | Modulus (Remainder) | 100 % 50 = 0 |
++ | Increment | var val=2; val++; Now val = 3 |
-- | Decrement | var val=2; val--; Now val = 1 |
Assignment Operators
Operator | Description | Example | |
---|
= | Assign | x = y | x = y |
+= | Add and assign | x += y | x = x + y |
-= | Subtract and assign | x -= y | x = x - y |
*= | Multiply and assign | x *= y | x = x * y |
/= | Divide and assign | x /= y | x = x / y |
%= | Modulus and assign | x %= y | x = x % y |
Comparison Operators
Operator | Description |
---|
== | Is equal to |
=== | Is equal value and equal type |
!= | Is not equal |
!== | Is not equal value or not equal type |
> | Is greater than |
< | Is less than |
>= | Is greater than or equal to |
<= | Is less than or equal to |
? | ternary operator |
Logical Operators
Operator | Description |
---|
&& | Logical AND |
|| | Logical OR |
! | Logical Not |
Bitwise Operators
Operator | Description |
---|
& | AND |
| | OR |
~ | NOT |
^ | XOR |
<< | Left shift |
>> | Right shift |
>>> | Unsigned right shift |