var i=5; if(i+=1&&i++){ console.log(i); }结果是10 咋运行的
1 回答

繁花如伊
TA贡献2012条经验 获得超12个赞
运算符优先级问题.
Javascript operator precedence tablepostfix ++
> &&
> +=
.
相当于(i+=(1&&(i++)))
. 此外,由于 Javascript 中逻辑运算符会返回对象, 所以1&&5
结果为5
. 所以是10
.
添加回答
举报
0/150
提交
取消