➢The assignment operator (=) assigns a value to a variable.
➢The additionoperator (+) adds numbers:.
EXAMPLE:
var x = 2;
var y = 3;
var Z = x + y;
➢The multiplication operator (*) multiplies numbers.
EXAMPLE:
var x = 2;
var y = 3;
var Z = x * y;
➢Arithmetic operators are used to perform arithmetic on numbers:
Operator |
Description |
+ |
Addition |
- |
Subraction |
* |
Mutiplication |
** |
Exponentiation (ES2016) |
/ |
Division |
% |
Modulus (Division Remainder) |
++ |
Increment |
-- |
Decrement |
➢A typical arithmetic operation operates on two numbers.
➢The two numbers can be literals:
Value |
Operator |
Description |
Example |
21 |
( ) |
Expression grouping |
(3 + 4) |
20 |
. |
Member |
person.name |
20 |
[] |
Member |
person["name"] |
20 |
() |
Function call |
myFunction() |
20 |
new |
Create |
new Date() |
18 |
++ |
Postfix Increment |
i++ |
18 |
-- |
Postfix Decrement |
i-- |
17 |
++ |
Prefix Increment |
++i |
17 |
-- |
Prefix Decrement |
--i |
17 |
! |
Logical not |
!(x==y) |
17 |
typeof |
Type |
typeof x |
16 |
** |
Exponentiation (ES2016) |
10 ** 2 |
15 |
* |
Multiplication |
10 * 5 |
15 |
/ |
Division |
10 / 5 |
15 |
% |
Division Remainder |
10 % 5 |
14 |
+ |
Addition |
10 + 5 |
14 |
- |
Subtraction |
10 - 5 |
13 |
<< |
Shift left |
x << 2 |
13 |
>> |
Shift right |
x >> 2 |
13 |
>>> |
Shift right (unsigned) |
x >>> 2 |
12 |
< |
Less than |
x < y |
12 |
<= |
Less than or equal |
x <= y |
12 |
> |
Greater than |
x > y |
12 |
>= |
Greater than or equal |
x >= y |
12 |
in |
Property in Object |
"PI" in Math |
12 |
instanceof |
Instance of Object |
instanceof Array |
11 |
== |
Equal |
x == y |
11 |
=== |
Strict equal |
x === y |
11 |
!= |
Unequal |
x != y |
11 |
!== |
Strict unequal |
x !== y |
10 |
& |
Bitwise AND |
x & y |
9 |
^ |
Bitwise XOR |
x ^ y |
8 |
| |
Bitwise OR |
x | y |
7 |
&& |
Logical AND |
x && y |
6 |
|| |
Logical OR |
x || y |
5 |
?? |
Nullish Coalescing |
x ?? y |
4 |
? : |
Condition |
? "Yes" : "No" |
3 |
+= |
Assignment |
x += y |
3 |
/= |
Assignment |
x /= y |
3 |
-= |
Assignment |
x -= y |
3 |
*= |
Assignment |
x *= y |
3 |
%= |
Assignment |
x %= y |
3 |
<<= |
Assignment |
x <<= y |
3 |
>>= |
Assignment |
x >>= y |
3 |
>>>= |
Assignment |
x >>>= y |
3 |
&= |
Assignment |
x &= y |
3 |
^= |
Assignment |
x ^= y |
3 |
|= |
Assignment |
x |= y |
2 |
yield |
Pause Function |
yield x |
1 |
, |
Comma |
5 , 6 |