运算符优先顺序(Order of Precedence of Operators)
以下是按evaluation顺序列出的运算符优先顺序。
| 优先级 | 描述 | 运算符 |
|---|---|---|
| 1 | Postfix increment and decrement | ++, — |
| 1 | New expression | new |
| 1 | Array subscripting | |
| 1 | Member access | |
| 1 | Function-like call | |
| 1 | Parentheses | ( |
| 2 | Prefix increment and decrement | ++, — |
| 2 | Unary plus and minus | +, - |
| 2 | Unary operations | delete |
| 2 | Logical NOT | ! |
| 2 | Bitwise NOT | ~ |
| 3 | Exponentiation | ** |
| 4 | Multiplication, division and modulo | *, /, % |
| 5 | Addition and subtraction | +, - |
| 6 | Bitwise shift operators | <<, >> |
| 7 | Bitwise AND | & |
| 8 | Bitwise XOR | ^ |
| 9 | Bitwise OR | | |
| 10 | Inequality operators | <, >, <=, >= |
| 11 | Equality operators | ==, != |
| 12 | Logical AND | && |
| 13 | Logical OR | || |
| 14 | Ternary operator | |
| 15 | Assignment operators | =, |=, ^=, &=, <<=, >>=, +=, -=, *=, /=, %= |
| 16 | Comma operator | , |
