identity-operator - javascript ... operator es6 - JavaScript中==和==的区别

JS Object equal / javascript / comparison-operators / equality-operator

JavaScript中 ===== 有什么区别?我也看到过 !=!== 运算符。还有更多这样的运营商吗?

Jonas Wilms



Answer #1

3个等号意味着 "没有类型强制的平等"。使用三等号,这些值在类型上也必须相等。

0 == false   // true
0 === false  // false, because they are of a different type
1 == "1"     // true, automatic type conversion for value only
1 === "1"    // false, because they are of a different type
null == undefined // true
null === undefined // false
'0' == false // true
'0' === false // false