【JavaScript 相等’==’和恒等’===’的区别】([difference between JavaScript equality ‘= =’ and identity ‘= =’])

在表达式两边的数据类型不一致时,会隐式转化为相同数据类型,然后对值进行比较

==

不会进行类型转换,在比较时对值和两边的数据类型进行比较。

===
console.log(1=='1')      // true
console.log(1==='1');    // false
console.log(1===1);      // true
 
console.log(undefined == null)    // true
console.log(undefined === null)   // false
————————

< strong > when the data types on both sides of the expression are inconsistent, they will be implicitly converted to the same data type, and then the values will be compared < / strong >

==

< strong > type conversion will not be performed. During comparison, values and data types on both sides are compared

===
console.log(1=='1')      // true
console.log(1==='1');    // false
console.log(1===1);      // true
 
console.log(undefined == null)    // true
console.log(undefined === null)   // false