赋值
1 2 3 4 5 6
| let a = {n:1} let b = a a.x = a = {n:2}
console.log(a.x) console.log(b.x)
|
非严格相等
1 2 3 4 5 6 7 8 9 10 11
| let a = { n: 1 valueOf: function() { return this.n*2 } } console.log( a == 1 && a == 2 && a == 3 )
|
加法
1 2 3 4 5 6
| console.log(null + undefined) console.log(NaN + '1') console.log(1 + true) console.log({n:1} + 1) console.log([1,2] + 1) {valueOf:function(){return this},toString:function(){return this}} + 1
|
与/或
布尔判定:false、null、undefined、’’、0、NaN被判定为假,其他均被判定为真
1 2 3 4
| console.log(2 && 4) console.log(2 || 4) let a = obj.a || 'default'
|