Operator
|
Description
|
Example
|
Result
|
+
|
Adding one value to another (directly or by variables).
|
a1= 3.5
a2= 4 + a1 |
a2 becomes 7.5
|
-
|
Subtracting one value from another
|
b1= 3.5
b2= 4 - a1 - .5 |
b2 becomes 0
|
*
|
Multiplying one value by another
|
c1= 2
c2= c1*c1 +1 |
c2 becomes 5
|
/
|
Dividing one value by another
|
d1= 90
d2= d1/10 + 1 |
d2 becomes 10
|
%
|
Remained value from dividing of it by another value
|
e1= 7
e2= d1 % 4 |
e2 becomes 3
|
++
|
Add one to a variable
|
f= 8
f++ |
f becomes 9
|
--
|
Subtract one from a variable
|
g= 3.7
g-- |
g becomes 2.7
|
+= num
|
Add a number to a variable current value
|
h= 5
h += 2 |
h becomes 7
|
-= num
|
Subtract a number from a variable current value
|
i= 5
i -= 7 |
i becomes 3
|
*= num
|
Multiply a variable by a number
|
j= 5
j *= 2 |
j becomes 10
|
/= num
|
Divide a variable by a number
|
k= 5
k /= 2 |
k becomes 2.5
|
%= num
|
A variable value becomes its remaineder from its division by a number
|
l= 5
l %= 2 |
l becomes 1
|
Code
|
Result
|
Result= 2+3*5+18/6+(7-4)%2
alert (Result) |
?
|