[英]operator precedence in javascript
I am reading operator precedence on this page . 我正在阅读此页面上的运算符优先级。 It shows "===" has higher precedence than "||"
它显示“ ===“的优先级高于“ ||” operator.
操作员。 If it is true, then "a === doesThisHappen()" will run first.
如果为真,则将首先运行“ a === didThisHappen()”。 But why I did not get console.log('This happens!')?
但是为什么我没有得到console.log('这发生了!')?
var a;
a = 1;
function doesThisHappen() {
console.log('This happens!');
return 0;
}
if (a || a === doesThisHappen()) {
console.log('Something is there.');
}
Order of evaluation and operator precedence are orthogonal concepts. 评估顺序和运算符优先级是正交的概念。 In
a || b
在
a || b
a || b
the left side a
is evaluated first no matter what the right side b
contains. a || b
左侧a
首先计算无论什么右侧b
包含。 More over, if the left side evaluates to true the right side is not evaluated. 此外,如果左侧的评估结果为true,则不会评估右侧。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.