JavaScript is such a weak type of language, in the judgment of equality is very troublesome, obviously not a thing, but equal. This example shows the equality of NULL, undefined, 0, false, and "". var arr = [null, undefined, 0, false, "];
var str = "";
for (var i = 0; i < arr. length; i++)
{
for (var j = i + 1; j < arr. length; j + +)
{
if (arr[i] = = Arr[j])
{
str = Arr[i] + "= =" + ((J!= 4)? ARR[J]: "\" \ "") + "\ n";
}
Else
{
str = arr[i] + "!=" + ((J!= 4)? ARR[J]: "\" \ "") + "\ n";
}
}
}
Result NULL = = undefined
Null!= 0
Null!= False
Null!= ""
Undefined!= 0
Undefined!= false
Undefined!= ""
0 = False
0 = ""
false = = ""
It can be seen that null and undefined are in a gang, and 0, False, "" is another gang.
How to eliminate interference.
Because of the different data types are waiting, to eliminate interference, such as let 0 not equal to "", how to do it. with identity = = = or!==. So that they are not equal to anyone else.