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

2024-05-03

有什么区别== and ===在 JavaScript 中?我也见过!= and !==运营商。还有更多这样的运营商吗?


看看这里:http://longgoldenears.blogspot.com/2007/09/triple-equals-in-javascript.html http://longgoldenears.blogspot.com/2007/09/triple-equals-in-javascript.html

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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

JavaScript 中 == 和 === 的区别[重复] 的相关文章

随机推荐