HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

JavaScript Operator Precedence

Operator precedence in JavaScript determines the order in which operators are evaluated when expressions are parsed and executed.

Operators with higher precedence are evaluated first, while those with lower precedence are evaluated later.

If operators have the same precedence, their evaluation order is determined by their associativity, which can be either left-to-right or right-to-left.

Here's an overview of operator precedence in JavaScript:

Operator Precedence Values

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name
;17 [] Member Of person["name"]
17 ?. Optional Chaining ES2020 x ?. y
17 () Function Call myFunction()
17 new New with Arguments new Date("June 5,2022")
16 new New without Arguments new Date()

Increment Operators

Postfix increments are executed before prefix increments

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name
;17 [] Member Of person["name"]
17 ?. Optional Chaining ES2020 x ?. y
17 () Function Call myFunction()
17 new New with Arguments new Date("June 5,2022")
16 new New without Arguments new Date()

NOT Operators

Postfix increments are executed before prefix increments

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name

Unary Operators

Postfix increments are executed before prefix increments

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name
;17 [] Member Of person["name"]
17 ?. Optional Chaining ES2020 x ?. y
17 () Function Call myFunction()
17 new New with Arguments new Date("June 5,2022")
16 new New without Arguments new Date()

Arithmetic Operators

Postfix increments are executed before prefix increments

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name
;17 [] Member Of person["name"]
17 ?. Optional Chaining ES2020 x ?. y
17 () Function Call myFunction()
17 new New with Arguments new Date("June 5,2022")
16 new New without Arguments new Date()

Shift Operators

Postfix increments are executed before prefix increments

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name
;17 [] Member Of person["name"]
17 ?. Optional Chaining ES2020 x ?. y
17 () Function Call myFunction()
17 new New with Arguments new Date("June 5,2022")
16 new New without Arguments new Date()

Relational Operators

Postfix increments are executed before prefix increments

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name
;17 [] Member Of person["name"]
17 ?. Optional Chaining ES2020 x ?. y
17 () Function Call myFunction()
17 new New with Arguments new Date("June 5,2022")
16 new New without Arguments new Date()

Comparison Operators

Postfix increments are executed before prefix increments

Val Operator Description Example
18 ( ) /Expression Grouping (100 + 50) * 3
17 . Member Of person.name
;17 [] Member Of person["name"]
17 ?. Optional Chaining ES2020 x ?. y
17 () Function Call myFunction()
17 new New with Arguments new Date("June 5,2022")
16 new New without Arguments new Date()

Bitwise Operators

Postfix increments are executed before prefix increments

& Bitwise AND
^ Bitwise XOR
| Bitwise OR

Logical Operators

Postfix increments are executed before prefix increments

&& Logical AND
|| Logical OR
?? Nullish Coalescing ES2020

Conditional (ternary) Operator

Postfix increments are executed before prefix increments

?: Condition

Assignment Operators

Assignments are executed after other operations

= Simple Assignment a=b
: Colon Assignment a:b
-= Subtraction Assignment a-=
+= Addition Assignment a+=b
*= Multiplication Assignment a*=
**= Exponentiation Assignment a**=b
/= Division Assignment a/=b
%= Remainder Assignment a%=b
%= Remainder Assignment a%=b
<<= Left Shift Assignment a<<=b
>>= Right Shift Assignment a>>=b
>>>= Unsigned Right Shift a>>>=b