【運算子】

以下是運算子,在敘述計算公式時需要注意優先順序,避免不必要的計算錯誤。

Precedence
Description
Operator

1

Postfix increment and decrement

++, --

New expression

new <typename>

Array subscripting

<array>[<index>]

Member access

<object>.<member>

Function-like call

<func>(<args...>)

Parentheses

(<statement>)

2

Unary minus

-

Unary operations

delete

Logical NOT

!

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

<conditional> ? <if-true> : <if-false>

Assignment operators

=, |=, ^=, &=, <<=, >>=, +=, -=, *=, /=, %=

15

Comma operator

,

Last updated