Operator precedence in JavaScript is a set of rules. This rule controls the order in which operators are executed when evaluating an expression. Operators with higher precedence are executed before operators with lower precedence. For example, multiplication is performed before addition.
The following table lists JavaScript operators from highest to lowest precedence. Operators with the same precedence are evaluated from left to right.
运算符 | 描述 |
. [] () | 字段访问、数组下标、函数调用以及表达式分组 |
-- - ~ ! delete new typeof void | 一元运算符、返回数据类型、对象创建、未定义值 |
* / % | 乘法、除法、取模 |
- | 加法、减法、字符串连接 |
<< >> >>> | 移位 |
< <= > >= instanceof | 小于、小于等于、大于、大于等于、instanceof |
== != === !== | 等于、不等于、严格相等、非严格相等 |
& | 按位与 |
^ | 按位异或 |
| | 按位或 |
&& | 逻辑与 |
|| | 逻辑或 |
?: | 条件 |
= oP= | 赋值、运算赋值 |
, | 多重求值 |
Parentheses can be used to change the order of evaluation determined by operator precedence. This means that the expression enclosed in parentheses should all be evaluated before it is used in the rest of the expression.
There are five operators in this expression: =, *, (), , and another . According to the rules of operator precedence, they will be evaluated in the following order: (), , , *, =.
The expression inside the parentheses is evaluated first. There are two addition operators in parentheses. Because both addition operators have the same precedence, they are evaluated from left to right. First add 96 and 3, then add that sum to 45, and you get 144.
Then comes the multiplication operation. 78 times 144 gives us 11232.
A is the assignment operation at the end. Assign 11232 to z.
=== operator: If the two value types are different, return false. If both values are of type number and have the same value, return true. If both values are string, and the String contents of the two values are the same, Return true If both values are true or both false, return true If both values point to the same Object, Arraya or function, return true If both values are null or both undefined, return true == operation Symbol: If two values have the same type, a === comparison will be performed and the comparison value of === will be returned. If the two values do not have the same type, it is also possible to return true. If one value is null and the other value is undefined, return true. If one value is a string and the other is a number, the string will be converted to a number and then compared. If a value is true, it will be converted to 1 and then compared. If a value is true, it will be converted to 0. If one value is an Object and the other is a number or string, the Object will be converted into the original type using valueOf() or toString() and then compared
Detailed source reference: http://www.jb51.net/article/17542.htm