Operator Precedence
- Operators are special functions
- infix means the operator sits in between the parameters
Precedence | Operator type | Associativity | Individual operators |
---|---|---|---|
18 Highest | n/a | ( … ) |
|
17 | left-to-right | … . … |
|
n/a | … [ … ] |
||
(with argument list) | n/a | new … ( … ) |
|
Function Call | n/a |
… ( … )
|
|
Optional chaining | left-to-right | ?. |
|
16 | (without argument list) | n/a | new … |
15 | n/a | … ++ |
|
… -- |
|||
14 | Logical NOT (!) | n/a | ! … |
Bitwise NOT (~) | ~ … |
||
Unary plus (+) | + … |
||
Unary negation (-) | - … |
||
++ … |
|||
-- … |
|||
typeof … |
|||
void … |
|||
delete … |
|||
await … |
|||
13 | Exponentiation (**) | right-to-left | … ** … |
12 | Multiplication (*) | left-to-right | … * … |
Division (/) | … / … |
||
Remainder (%) | … % … |
||
11 | Addition (+) | left-to-right | … + … |
Subtraction (-) | … - … |
||
10 | Bitwise Left Shift (<<) | left-to-right | … << … |
Bitwise Right Shift (>>) | … >> … |
||
Bitwise Unsigned Right Shift (>>>) | … >>> … |
||
9 | Less Than (<) | left-to-right | … < … |
Less Than Or Equal (<=) | … <= … |
||
Greater Than (>) | … > … |
||
Greater Than Or Equal (>=) | … >= … |
||
… in … |
|||
… instanceof … |
|||
8 | Equality (==) | left-to-right | … == … |
Inequality (!=) | … != … |
||
Strict Equality (===) | … === … |
||
Strict Inequality (!==) | … !== … |
||
7 | Bitwise AND (&) | left-to-right | … & … |
6 | Bitwise XOR (^) | left-to-right | … ^ … |
5 | Bitwise OR (|) | left-to-right | … | … |
4 | Logical AND (&&) | left-to-right | … && … |
3 | Logical OR (||) | left-to-right | … || … |
Nullish coalescing operator (??) | left-to-right | … ?? … |
|
2 | Assignment | right-to-left | … = … |
… += … |
|||
… -= … |
|||
… **= … |
|||
… *= … |
|||
… /= … |
|||
… %= … |
|||
… <<= … |
|||
… >>= … |
|||
… >>>= … |
|||
… &= … |
|||
… ^= … |
|||
… |= … |
|||
… &&= … |
|||
… ||= … |
|||
… ??= … |
|||
Conditional (ternary) operator | right-to-left (Groups on expressions after ? ) |
… ? … : … |
|
Arrow (=>) | n/a | … => … |
|
yield … |
|||
yield* … |
|||
Spread (...) | ... … |
||
1 | Comma / Sequence | left-to-right | … , … |