浅谈JS世界中&和&&

console.log(1&2); console.log(1&&2); 上面打印的结果是什么呢? 先别急着回答,我们先复习一下JS中的逻辑运算符&& 与,左边为真才走右边,左边为假只走左边。 在JS世界中,一共有这几种情况被认定为假:fase,undefined,'',null,0与神奇的NaN。 console.log(0&&1); 左边为假,不走了,打印结果为0; console.log(u
相关文章
相关标签/搜索