137
Operator Precedence Table
This table ranks JavaScript operators by their precedence, with the higher-precedence operators (executed first) at the top.
Operator Precedence | Operator | Description | Associativity | Example |
---|---|---|---|---|
1 | () | Grouping | L -> R | (expression) |
2 | . | Member of object | L -> R | Object_name.property |
2 | () | Function call | L -> R | Test() |
2 | new | To create objects | R -> L | New example() |
2 | [] | Member of object | L -> R | Object[“property”] |
3 | — | Postfix decrement | – | p–; |
3 | ++ | Postfix increment | – | p++ |
4 | — | Prefix decrement | R -> L | –p; |
4 | ++ | Prefix increment | R -> L | ++p; |
4 | typeof | To get the variable type | R -> L | typeof a; |
4 | ! | Logical not | R -> L | !a; |
4 | ~ | Bitwise not | R -> L | ~p |
4 | – | Unary minus | R -> L | -p |
4 | + | Unary plus | R -> L | +p |
4 | delete | To delete object property | R -> L | Delete arr[0] |
4 | void | Evaluates void | R -> L | Void(1) |
5 | ** | Exponentiation operator | R -> L | p ** q |
6 | * | Multiplication | L -> R | p * q |
6 | / | Division | L -> R | p / q |
6 | % | modulo | L -> R | p % q |
7 | + | Addition or plus operator | L -> R | p + q |
7 | – | Subtraction operator | L -> R | p – q |
8 | << | Left shift | L -> R | p << 2 |
8 | >> | Signed right shift | L -> R | p >> 2 |
8 | >>> | Unsigned right shift | L -> R | p >>> 2 |
9 | in | Property in object | L -> R | x in y |
9 | instanceof | Instance of object | L -> R | p instanceof Object |
9 | < | Less than | L -> R | p < q |
9 | <= | Less than or equal to | L -> R | p <= q |
9 | > | Greater than | L -> R | p > q |
9 | >= | Greater than or equal to | L -> R | p >= q |
10 | == | Equality | L -> R | p == q |
10 | != | Inequality | L -> R | p != q |
10 | === | Strict equality | L -> R | p === q |
10 | !== | Strict inequality | L -> R | p !== q |
11 | & | Bitwise AND | L -> R | p & q |
12 | ^ | Bitwise XOR | L -> R | p ^ q |
13 | | | Bitwise OR | L -> R | p | q |
14 | && | Logical AND | L -> R | p && q |
15 | || | Logical OR | L -> R | p || q |
16 | ?? | Nullish Coalescing | R -> L | p ?? q |
17 | = | Assignment | R -> L | p = q |
17 | : | Colon assignment | R -> L | p : q |
17 | += | Addition assignment | R -> L | p += q |
17 | -= | Subtraction assignment | R -> L | p -= q |
17 | *= | Multiplication assignment | R -> L | p *= q |
17 | /= | Division assignment | R -> L | p /= q |
17 | %= | Modulo assignment | R -> L | p %= q |
17 | **= | Exponentiation assignment | R -> L | p **= q |
17 | <<= | Left shift assignement | R -> L | p <<= q |
17 | >>= | Right shift assignment | R -> L | p >>= q |
17 | >>>= | Unsigned right shift assignment | R -> L | p >>>= q |
17 | &= | Bitwise AND assignment | R -> L | p &= q |
17 | ^= | Bitwise XOR assignment | R -> L | p ^= q |
17 | |= | Bitwise OR assignment | R -> L | p |= q |
17 | &&= | Logical AND assignment | R -> L | p &&= q |
17 | ||= | Logical OR assignement | R -> L | p ||= q |
17 | => | Arrow operator | – | (a, b )=> { // function code} |
17 | … | Spread operator | – | [… arr] |
18 | yield | Pause / Resume | R -> L | yield p; |
19 | , | Comma operator | L -> R | (5, 10, 15) |