| + |
Addition |
| - |
Subtraction |
| * |
Multiplication |
| / |
Division |
| % |
Modulus: the remainder after division; e.g. 10 % 3 yields 1. |
| ++ |
Unary increment: this operator only takes one operand.
The operand's value is increased by 1. The value returned depends on whether
the ++ operator is placed before or after the operand; e.g. ++x will
return the value of x following the increment whereas x++ will return
the value of x prior to the increment. |
| -- |
Unary decrement: this operator only takes one operand.
The operand's value is decreased by 1. The value returned depends on whether
the -- operator is placed before or after the operand; e.g. --x will
return the value of x following the decrement whereas x-- will return
the value of x prior to the decrement. |
| - |
Unary negation: returns the negation of operand. |
| == |
"Equal to" returns true if operands are equal. |
| != |
"Not equal to" returns true if operands are not equal. |
| > |
"Greater than" returns true if left operand is greater
than right operand. |
| >= |
"Greater than or equal to" returns true if left operand
is greater than or equal to right operand. |
| < |
"Less than" returns true if left operand is less than
right operand. |
| <= |
"Less than or equal to" returns true if left operand
is less than or equal to right operand. |
| && |
"And" returns true if both operands are true. |
| || |
"Or" returns true if either operand is true. |
| ! |
"Not" returns true if the negation of the operand
is true (e.g. the operand is false). |
| "dog" + "bert" |
yields |
"dogbert" |
| = |
Assigns the value of the righthand operand to the
variable on the left. Example: total=100; Example: total=(price+tax+shipping) |
| += (also -=, *=, /=) |
Adds the value of the righthand operand to the lefthand
variable and stores the result in the lefthand variable. Example: total+=shipping (adds value of shipping to total and assigned result to total) |
| &= (also |=) |
Assigns result of (lefthand operand && righthand
operand) to lefthand operand. |
| Conditional operator (condition) ? trueVal : falseVal |
Assigns a specified value to a variable if a condition
is true, otherwise assigns an alternate value if condition is false. Example: preferredPet = (cats > dogs) ? "felines" : "canines" If (cats>dogs), preferredPet will be assigned the string value "felines," otherwise it will be assigned "canines". |
| typeof operand |
Returns the data type of operand. Example -- test a variable to determine if it contains a number: if (typeof total=="number") ... |
| Top |