Comparison of 0 with some imaginary value:
0 and false
0==false
true
0 and '':
0==''
true
0 and []:
0==[]
true
0 given NaN:
0 == NaN
false
0与undefined
0==undefined
false
0 and null
0==null
false
0 and {}
0=={}
false
''Comparison of empty value with some value
Null is equal to false,[]
I don't know what the comparison of these values is. Whether these values are equal together can be used in some js
Let's add the relationship between undefined, null, empty string, false, true in js.
Because I have seen in other books that undefined, null, and empty strings can be used as false in the if statement, I always thought that undefined, null, empty strings, and false are equal;
Some time ago, I accidentally found that undefined==null when writing code; but these two are not equal to null characters and false; to understand the relationship between them, I interviewed on the browser again; the following are the experimental results
false为boolean型;‘'为字符串型;当不考虑他们的数据类型时两者相等;当考虑数据类型时两者不相等
实验发现null的数据类型为object ;无论是否考虑数据类型空字符和空都不相等
当不考虑字符类型时发现undefined等于null 当考虑字符类型时undefined不等于空