JavaScript operators table.
An operator is used to transform one (unary) or two (binary) values into a single resultant value. The values are the operands. The combination of the operator and its operands is the expression.
For basic examples start from JavaScript: Basics
Also see JavaScript: Strings and JavaScript: Maths for further examples and expressions.
| Operator | Precedence | Associativity | Type of operand | Brief description |
|---|---|---|---|---|
| . | 15 | left-to-right | object | access a property or method (dot notation) |
| [] | 15 | left-to-right | array | array indexing |
| () | 15 | left-to-right | function arguments | calls to a function |
| new | 15 | right-to-left | call to object constructor | creates a new object |
| ++ | 14 | right-to-left | value | increment |
| -- | 14 | right-to-left | value | decrement |
| - | 14 | right-to-left | number | unary minus or negative number |
| + | 14 | right-to-left | number | unary plus or positive number |
| ! | 14 | right-to-left | boolean | logical NOT |
| typeof | 14 | right-to-left | any type | returns data type |
| delete | 14 | right-to-left | value | deletes a custom object property, method, or array element |
| void | 14 | right-to-left | any type | returns 'undefined' value |
| * | 13 | left-to-right | numbers | multiplication |
| / | 13 | left-to-right | numbers | division |
| % | 13 | left-to-right | numbers | modulus |
| + | 12 | left-to-right | numbers | addition |
| - | 12 | left-to-right | numbers | subtraction |
| + | 12 | left-to-right | strings | concatenation |
| < | 10 | left-to-right | numbers, strings | less than |
| <= | 10 | left-to-right | numbers, strings | less than or equal to |
| > | 10 | left-to-right | numbers, strings | greater than |
| >= | 10 | left-to-right | numbers, strings | greater than or equal to |
| == | 9 | left-to-right | any type | test for equality |
| != | 9 | left-to-right | any type | test for inequality |
| && | 5 | left-to-right | booleans | logical AND |
| || | 4 | left-to-right | booleans | logical OR |
| = | 2 | right-to-left | value, any type | assignment |
| += | 2 | right-to-left | value, any type | operation and assignment,
example:
sVar+=tVar is equivalent to:sVar=sVar+tVar |
Back to top.
Copyright © 2006-2012 justfigures.co.uk
