Usually in the following statement structure to determine the true and false
If branch statement
While Loop statement
For the second statement in the
Such as
Copy Code code as follows:
if (boo) {
Do something
}
while (Boo) {
Do something
}
6 values in JavaScript are "false" and the six values are
False
Null
Undefined
0
' (empty string)
NaN
In this case, false itself is a Boolean type, and the other 5 are not.
In addition to these 6, the other is "true", including objects, arrays, regular, functions, and so on. Note that ' 0 ', ' null ', ' false ', {}, [] are also true values.
Although these six values are "false", they are not all equal
Copy Code code as follows:
Console.log (false = null)//False
Console.log (false = = undefined)//False
Console.log (false = = 0)/True
Console.log (false = = ")//True
Console.log (false = NaN)//False
Console.log (null = = undefined)//True
Console.log (Null = = 0)//False
Console.log (Null = = ")//False
Console.log (null = NaN)//False
Console.log (undefined = = 0)//False
Console.log (undefined = = ")//False
Console.log (undefined = = NaN)//False
Console.log (0 = = ")//True
Console.log (0 = NaN)//False
for "= =", the above conclusions are drawn as follows
False, and 0, ' is true in addition to comparing itself to true
Null is true when compared to undefined, and in turn undefined is only null compared to true, without a second
0 In addition to false compared to true, there is also an empty string '
Null string ' out and false compared to true, there is also a number 0