JavaScript中==和===之间的区别[重复]

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

逆天L2020/03/09 20:22:42

===并且!==是严格的比较运算符:

JavaScript具有严格和类型转换相等性比较。为了strict相等,要比较的对象必须具有相同的类型,并且:

  • 当两个字符串在相同位置具有相同的字符序列,相同的长度和相同的字符时,它们是严格相等的。
  • Two numbers are strictly equal when they are numerically equal (have the same number value). NaN is not equal to anything, including NaN. Positive and negative zeros are equal to one another.
  • Two Boolean operands are strictly equal if both are true or both are false.
  • Two objects are strictly equal if they refer to the same Object.
  • Null and Undefined types are == (but not ===). [I.e. (Null==Undefined) is true but (Null===Undefined) is false]

Comparison Operators - MDC