!==运算符在javascript中做了什么?

Vas*_*nth 2 javascript

if (description !== undefined)
Run Code Online (Sandbox Code Playgroud)

我在书呆子晚餐教程中找到了这个.

Sar*_*raz 5

身份运营商不仅要检查价值,还要检查类型.

例:

if (4 === 4)  // both type and value are same
{
  // true
}
Run Code Online (Sandbox Code Playgroud)

但

if (4 == "4")  // value is same but type is different but == used
{
  // true
}
Run Code Online (Sandbox Code Playgroud)

和

if (4 === "4")  // value is same but type is different but === used
{
  // false
}
Run Code Online (Sandbox Code Playgroud)

您应该使用===或!==一旦确定值和类型.