JavaScript. Operators priority

Operators priority

Operator precedence determines the order in which operators in an expression are executed. There are a number of operators that have the same precedence. In this case, the order in which operators are executed is determined by the direction of computation, which is called associativity. The direction of evaluation for operators with equal precedence can be:

  • from left to right;
  • from right to left.

Below is a table of all JavaScript language operators in descending order of precedence.

Priority Operator Associativity Description

0

( )

Grouping

1

 

 

[ ]

.

new

From left to right

From left to right

Access to the array item.

Access to the property.

Creating an object with a list of arguments

2

function

new

From left to right

From left to right

Function call

Creating an object without a list of arguments

3 ++

Postfix increment

Postfix decrement

4

!

~

++

––

typeof

void

delete

From right to left

From right to left

From right to left

From right to left

From right to left

From right to left

From right to left

From right to left

Logical negation

Bitwise logical negation

Negation (negative number)

Prefix increment

Prefix decrement

Type information

Evaluate the expression and return undefined

Deleting

5 *

/

%

From left to right

From left to right

From left to right

Multiplication

Division

Remainder of the division

6 +

From left to right

From left to right

Addition

Substraction

7 <<

>>

>>

From left to right

From left to right

From left to right

Bitwise left shift

Bitwise right shift.

Bitwise unsigned right shift.

8 <

<=

>

>=

in

instanceof

From left to right

From left to right

From left to right

From left to right

From left to right

From left to right

Less

Less or equal

More

More or equal

Checking if a property exists

Type checking

9 ==

!=

===

!==

From left to right

From left to right

From left to right

From left to right

Проверка на равенство

Checking for inequality

Strict equality check

Checking strict inequality

10 & From left to right Bitwise AND
11 ^ From left to right Bitwise exclusive OR (XOR)
12 | From left to right Bitwise OR
13 && From left to right Logical AND
14 || From left to right Logical OR
15 ?: From right to left Ternary conditional operator
16 =

+=

-=

*=

/=

%=

<<=

>>=

>>>

&=

^=

!=

From right to left Varieties of the assignment operator
17 yield From right to left Stopping and restoring a generator function
18 , From left to right Evaluates both operands and returns the value of the other