| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/zh-TW/docs/Web/JavaScript/Reference/Operators/Operator_precedence | [Back] [Original] |
Get to know MDN better
Operator precedenceoperands
console.log(3 + 4 * 5); // 3 + 20
// Expected output: 23
console.log(4 * 3 ** 2); // 4 * 9
// Expected output: 36
let a;
let b;
console.log((a = b = 5));
// Expected output: 5
a OP b OP c
(Left-associativity) (a OP b) OP c(right-associativity) a OP (b OP c) (Assignment operators)
a = b = 5;
a b 5 (Assignment operator) b 5 a 5
(19) (1)
Precedence |
Operator type |
Associativity |
Individual operators |
|---|---|---|---|
| 19 | Grouping | ( ) |
|
| 18 | Member Access | . |
|
| Computed Member Access | [ ] |
||
new (with argument list) |
new ( ) |
||
( )
|
|||
| Optional chaining | ?. |
||
| 17 |
new (without argument list)
|
new |
|
| 16 | ++ |
||
-- |
|||
| 15 | Logical NOT | ! |
|
| Bitwise NOT | ~ |
||
| Unary Plus | + |
||
| Unary Negation | - |
||
++ |
|||
-- |
|||
typeof |
typeof |
||
void |
void |
||
delete |
delete |
||
await |
await |
||
| 14 | Exponentiation | ** |
|
| 13 | Multiplication | * |
|
| Division | / |
||
| Remainder | % |
||
| 12 | Addition | + |
|
| Subtraction | - |
||
| 11 | Bitwise Left Shift | << |
|
| Bitwise Right Shift | >> |
||
| Bitwise Unsigned Right Shift | >>> |
||
| 10 | Less Than | < |
|
| Less Than Or Equal | <= |
||
| Greater Than | > |
||
| Greater Than Or Equal | >= |
||
in |
in |
||
instanceof |
instanceof |
||
| 9 | Equality | == |
|
| Inequality | != |
||
| Strict Equality | === |
||
| Strict Inequality | !== |
||
| 8 | Bitwise AND | & |
|
| 7 | Bitwise XOR | ^ |
|
| 6 | Bitwise OR | | |
|
| 5 | Logical AND | && |
|
| 4 | Logical OR | || |
|
| Nullish Coalescing | ?? |
||
| 3 | ? : |
||
| 2 | = |
||
+= |
|||
-= |
|||
**= |
|||
*= |
|||
/= |
|||
%= |
|||
<<= |
|||
>>= |
|||
>>>= |
|||
&= |
|||
^= |
|||
|= |
|||
&&= |
|||
||= |
|||
??= |
|||
| 1 | Comma / Sequence | , |
This page was last modified on 2026526 by MDN contributors.
Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |