Unsure of the order of operations for the following expressions?
A>b?c:d+e
A&&b==c
The following table is clear, the following table is listed by priority from highest to lowest, with the same priority evaluated in left-to-right order.
Operator |
Describe |
. [] () |
field access, array subscripts, function calls, and expression grouping |
++ -- - ~ ! Delete new typeof void |
Unary operators, return data types, object creation, undefined values |
* / % |
Multiplication, division, modulo |
+ - + |
addition, subtraction, string connection |
<< >> >>> |
Shift |
< <= > >= instanceof |
Less than, equal to, greater than, greater than or equal to, instanceof |
== != === !== |
Equal, not equal, strictly equal, not strictly equal |
& |
Bitwise-AND |
^ |
Bitwise XOR OR |
| |
Bitwise OR |
&& |
Logic and |
|| |
Logical OR |
?: |
Conditions |
= op= |
Assignment, Operation assignment |
, |
Multi-value evaluation |
Precedence of operators in JS