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

JavaScript

米亚伽罗村村

2020-03-09

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

第243篇《JavaScript中==和===之间的区别\[重复\]》来自Winter(https://github.com/aiyld/aiyld.github.io)的站点

1个回答
逆天L 2020.03.09

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

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

问题类别

JavaScript Ckeditor Python Webpack TypeScript Vue.js React.js ExpressJS KoaJS CSS Node.js HTML Django 单元测试 PHP Asp.net jQuery Bootstrap IOS Android