在JavaScript中!=和!==相同

可能重复:
Javascript === vs ==:这与我使用的“平等”运算符有关吗?
Javascript运算符!==

看看这个提交

在JavaScript中是!=!==相同吗?

[1]:


他们微妙地不一样。

!=检查值
!==检查值和类型

'1' != 1   // false (these two are the same)
'1' !== 1 // true (these two are **not** the same).

在前面的例子中。 表达式的前半部分是一个字符串,后半部分是一个整数。


http://en.wikipedia.org/wiki/JavaScript_syntax#Operators

!==不一样

!=不相等

和“相同意味着相同和相同类型”。

http://docstore.mik.ua/orelly/webprog/jscript/ch05_04.htm

“在JavaScript中,数字,字符串和布尔值按值进行比较......另一方面,通过引用来比较对象,数组和函数。”

-

总之,它们是一样的吗? 不,因为对于类型相同和平等,还有一个额外的测试!==(over!=)。


不,这是不一样的。 请参阅此处的示例。

4 !== '4' returns true   (and 4 === '4' returns false)
4 != '4'  returns false  (and 4 == '4'  returns true)
链接地址: http://www.djcxy.com/p/3241.html

上一篇: In JavaScript is != same as !==

下一篇: What is exactly the meaning of "===" in javascript?