ARITHMETIC
Arithmetic
Operators are symbols that are used with variables to allow
us to perform certain functions, such as adding, subtracting
and etc. The table on the left lists the operators available
in JavaScript and describes what it does (assuming the two variables
x and y that have been declared and initialized with a value).
|
operator |
what
it does |
x
+ y (numeric) |
Adds
x and y |
x
+ y (string) |
Concatenates x and y |
x
- y |
Subtracts
x from y |
x
* y |
Multiplies
x b y |
x
/ y |
Divides
x by y |
x
% y |
Remainder of x / y , modulus |
x++,
++x |
x
= x + 1 |
x--,
--x |
x
= x - 1 |
-x |
Reverses
the sign of x |
|