一、==

  1. 对象和字符串比照,对象.toString()变为字符串
var a={ toString(){return ''} }console.log(a=='') // true

2、不说了,看代码

console.log(null==undefined)  // true 然而和其它值比拟不相等console.log(NaN==NaN)  // false 和本人都不相等,别说其它的了

3、除了以上,剩下都是先转化成数字再做比拟

  • 对象转数字:先调toString()转为字符串,再用Number()函数转为数字
var a={ toString(){return ''} }console.log(a==0) // true