JavaScript Operator Precedence
- Previous Page JS Operators
- Next Page JS Statements
Precedence describes the execution order of operations in arithmetic expressions.
Instance
In traditional mathematics, multiplication is executed first:
let x = 100 + 50 * 3;
When using parentheses, the operation within the parentheses is calculated first:
let x = (100 + 50) * 3;
When operators have the same precedence (such as + and -), they are calculated from left to right:
let x = 100 / 50 * 3;
Operator precedence valueExpression within parenthesesBeforeOther expressions are calculated. Function is used in the result for other expressionsBeforeExecute. |
|||
Value | Operator | Description | Example |
---|---|---|---|
18 | ( ) | Expression grouping | (100 + 50) * 3 |
17 | . | Member | car.name |
17 | [] | Member | car["name"] |
17 | ?. | Optional chaining ES2020 | x ?. y |
17 | () | Function call | myFunction() |
17 | new | Parameterized construction | new Date("June 6,2025") |
16 | new | No parameter construction | new Date() |
Increment operatorPostfix incrementBeforePrefix increment execution. |
|||
15 | ++ | Postfix increment | i++ |
15 | -- | Postfix decrement | i-- |
14 | ++ | Prefix increment | ++i |
14 | -- | Prefix decrement | --i |
NOT operator |
|||
14 | ! | Logical NOT | !(x==y) |
14 | ~ | Position NOT | ~x |
Unary Operators |
|||
14 | + | Unary Addition | +x |
14 | - | Unary Subtraction | -x |
14 | typeof | Data Type | typeof x |
14 | void | Evaluate Void | void(0) |
14 | delete | Property Deletion | delete myCar.color |
Arithmetic OperatorsPowerBeforeMultiplication Execute. Multiplication and DivisionBeforeAddition and Subtraction Execute. |
|||
13 | ** | Power ES2016 | 10 ** 2 |
12 | * | Multiplication | 10 * 5 |
12 | / | Division | 10 / 5 |
12 | % | Modulo | 10 % 5 |
11 | + | Addition | 10 + 5 |
11 | - | Subtraction | 10 - 5 |
11 | + | Concatenation | "Bill" + "Gates" |
Shift Operators |
|||
10 | << | Left Shift | x << 2 |
10 | >> | Right Shift (Signed) | x >> 2 |
10 | >>> | Right Shift (Unsigned) | x >>> 2 |
Relational Operators |
|||
9 | in | Property in Object | "PI" in Math |
9 | instanceof | Object Instance | x instanceof Array |
Comparison Operators |
|||
9 | < | Less Than | x < y |
9 | <= | Less Than or Equal | x <= y |
9 | > | Greater Than | x > y |
9 | >= | Greater Than or Equal | x >= Array |
8 | == | Equal | x == y |
8 | === | Strictly Equal | x === y |
8 | != | Not Equal | x != y |
8 | !== | Strictly Not Equal | x !== y |
Bitwise Operators |
|||
7 | & | Bit AND | x & y |
6 | ^ | Bit XOR | x ^ y |
5 | | | Bit OR | x | y |
Logical Operators |
|||
4 | && | Logical AND | x && y |
3 | || | Logical OR | x || y |
3 | ?? | Nullish Coalescing ES2020 | x ?? y |
Conditional (Ternary) Operator |
|||
2 | ? : | Conditional | ? "yes" : "no" |
Assignment OperatorAssignment in Other OperationsAfterExecute. |
|||
2 | = | Simple Assignment | x = y |
2 | += | Addition Assignment | x += y |
2 | -= | Subtraction Assignment | x -= y |
2 | *= | Multiplication Assignment | x *= y |
2 | **= | Power Assignment | x **= y |
2 | /= | Division Assignment | x /= y |
2 | %= | Modulo Assignment | x %= y |
2 | <<= | Left Shift Assignment | x <<= y |
2 | >>= | Right Shift Assignment | x >>= y |
2 | >>= | Unsigned Right Shift | x >>>= y |
2 | &= | Bit AND Assignment | x &= y |
2 | |= | Bit OR Assignment | x |= y |
2 | ^= | Bitwise XOR Assignment | x ^= y |
2 | &= | Logical AND Assignment | x &= y |
2 | ||= | Logical OR Assignment | x ||= y |
2 | : | Colon Assignment | x : 5 |
2 | => | Arrow | x => y |
2 | yield | Pause/Resume | yield x |
2 | yield* | Delegation | yield* x |
2 | ... | Expansion | ...x |
1 | , | Comma | x, y |
- Previous Page JS Operators
- Next Page JS Statements