- ==进行类型转换,===不进行转换
console.log(1 === 1) //true
console.log(1 ==1) //true
console.log(1 == "1") //true
console.log(1 === "1")//false
- true转换为1,false转为0
console.log(true == 1) //true
console.log(false == 0) //true
console.log(true === 1) //false
console.log(false === 0) //false
- null == undefined,但两者跟任何其他都不相等
console.log('' == 0) //true
console.log(' ' == 0) //true
console.log(null == undefined) //true
console.log(null == 0) //false
console.log(undefined == '') //false
- NaN不确切数字,跟包括自身任何都不相等
console.log('false' == false) //false 'false' == 0
console.log(NaN == NaN) //false NaN不确切数字
console.log(NaN == false) //false
console.log(NaN === false) //false
- 对象比较地址,ab不相同,赋值是将指针指向对方地址,ac相等
var a={}
var b ={}
var c = a
console.log(a==b) //false
console.log(a===b) //false
console.log(a==c) //true
console.log(a===c) //true
网友评论