1 |
JavaScript expressions and basic operators are similar to C, PERL, and Java
|
2 |
Assignment operators:
|
3 |
= += -= *= /= %= <<= >>= >>>= &= ^= |=
-
x += y; // means x = x + y
-
x %= y; // means x = x % y (i.e., x mod y)
|
4 |
Conditional expressions are supported:
-
status = (age >= 18) ? "adult" : "minor"; /* sets status to "adult" if age is greater than or equal to 18; otherwise set to "minor" */
|
5 |
Arithmetic operators are as usual with the addition of ++ and --
-
y = ++x; // increments x; assigns this value to y
|