This article mainly introduces the false value application of the wonderful flower in JavaScript, the friend who need can refer to the following
Usually in the following statement structure needs to determine true and false If branch statements while Loop statement for the second statement of the , such as the code as follows: if (boo) { / /do something } while (boo) { //Do something } JavaScript 6 values are "false", these six values are &nbs P false null undefined 0 ' (empty string) nan This 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 code as follows: Console.log (false = null)//false Console.log (false = = Undefine d)//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&N Bsp Console.log (undefined = = ")//false console.log (undefined = = Nan)//false console.log (0 = ")//true console.log (0 = = Nan)//false for" = = ", above come The following conclusions False is true only if compared to itself, and 0, ' is also true null compared to undefined, and vice versa undefined is only null comparison to True, without a second 0 In addition to false to true, there is also an empty string ' empty string ' out and false compared to true, there is also a number 0