1the number 0
2the BigInt 0n
3the keyword null
4the keyword undefined
5the boolean false
6the number NaN
7the empty string "" (equivalent to '' or ``)
1// JS Essentials: Falsy Values
2
3false
4undefined
5null
6NaN
70 or +0 or -0
8"" or '' or `` (empty string)
9
10// Everything else is truthy
1false //The keyword false.
20 //The Number zero (so, also 0.0, etc., and 0x0).
3-0 //The Number negative zero (so, also -0.0, etc., and -0x0).
40n, -0n //The BigInt zero and negative zero (so, also 0x0n/-0x0n).
5"", '', `` //Empty string value.
6null //the absence of any value.
7undefined //the primitive value.
8NaN //not a number.
9
10document.all
11//Objects are falsy if and only if they have the [[IsHTMLDDA]] internal slot.
12//That slot only exists in document.all and cannot be set using JavaScript.
1 let a = false
2 let b = 0
3 let c = -0
4 let d = 0n
5 let e = ''
6 let f = null
7 let g = undefined
8 let h = NaN
1if (true)
2if ({})
3if ([])
4if (42)
5if ("0")
6if ("false")
7if (new Date())
8if (-42)
9if (12n)
10if (3.14)
11if (-3.14)
12if (Infinity)
13if (-Infinity)
14