JavaScript Operator Precedence

Prece­dence Group Operator Desription Associativity
18 Grouping (x) Grouping, [1]
17 Access and call x.y Member access, [2] left-to-right
x?.y Optional chaining, [2]
x[y] Computed member access, [3]
new x(y) new with argument list, [4]
x(y) Function call, [4]
import(x) import(), [4]
16 New new x new without argument list
15 Postfix operators x++ Postfix increment, [5]
x-- Postfix decrement, [5]
14 Prefix operators ++x Prefix increment, [6]
--x Prefix decrement, [6]
!x Logical NOT
~x Bitwise NOT
+x Unary plus
-x Unary negation
typeof x typeof
void x void
delete x delete, [7]
await x await
13 Exponentiation x ** y Exponentiation, [8] right-to-left
12 Multiplicative operators x * y Multiplication left-to-right
x / y Division
x % y Remainder
11 Additive operators x + y Addition left-to-right
x - y Subtraction
10 Bitwise shift x << y Left shift left-to-right
x >> y Right shift
x >>> y Unsigned right shift
9 Relational operators x < y Less than left-to-right
x <= y Less than or equal
x > y Greater than
x >= y Greater than or equal
x in y in
x instanceof y instanceof
8 Equality operators x == y Equality left-to-right
x != y Inequality
x === y Strict equality
x !== y Strict inequality
7 Bitwise operators x & y Bitwise AND left-to-right
6 x ^ y Bitwise XOR
5 x | y Bitwise OR
4 Logical operators x && y Logical AND left-to-right
3 x || y Logical OR
x ?? y Nullish coalescing operator, [9]
2 Assignment x = y Assignment, [10] right-to-left
x += y Addition assignment, [10]
x -= y Subtraction assignment, [10]
x **= y Exponentiation assignment, [10]
x *= y Multiplication assignment, [10]
x /= y Division assignment, [10]
x %= y Remainder assignment, [10]
x <<= y Left shift assignment, [10]
x >>= y Right shift assignment, [10]
x >>>= y Unsigned right shift assignment, [10]
x &= y Bitwise AND assignment, [10]
x ^= y Bitwise XOR assignment, [10]
x |= y Bitwise OR assignment, [10]
x &&= y Logical AND assignment, [10]
x ||= y Logical OR assignment, [10]
x ??= y Nullish coalescing assignment, [10]
Miscellaneous x ? y : z Conditional (ternary) operator, [11] right-to-left
x => y Arrow, [12] right-to-left
yield x yield
yield* x yield*
...x Spread, [13]
1 Comma x, y Comma operator left-to-right

Notes:

  1. The operand can be any expression.
  2. The "right-hand side" must be an identifier.
  3. The "right-hand side" can be any expression.
  4. The "right-hand side" is a comma-separated list of any expression with precedence > 1 (i.e. not comma expressions).
  5. The operand must be a valid assignment target (identifier or property access). Its precedence means new Foo++ is (new Foo)++ (a syntax error) and not new (Foo++) (a TypeError: (Foo++) is not a constructor).
  6. The operand must be a valid assignment target (identifier or property access).
  7. The operand cannot be an identifier or a private property access.
  8. The left-hand side cannot have precedence 14.
  9. The operands cannot be a logical OR (||) or logical AND (&&) operator without grouping.
  10. The "left-hand side" must be a valid assignment target (identifier or property access).
  11. The associativity means the two expressions after ? are implicitly grouped.
  12. The "left-hand side" is a single identifier or a parenthesized parameter list.
  13. Only valid inside object literals, array literals, or argument lists.