falsy value javascript code example
Example 1: javascript falsy values
the number 0
the BigInt 0n
the keyword null
the keyword undefined
the boolean false
the number NaN
the empty string "" (equivalent to '' or ``)
Example 2: javascript falsy
0
''
undefined
null
NaN
Example 3: js falsy values
let a = false
let b = 0
let c = -0
let d = 0n
let e = ''
let f = null
let g = undefined
let h = NaN
Example 4: javascript falsy values
if (true)
if ({})
if ([])
if (42)
if ("0")
if ("false")
if (new Date())
if (-42)
if (12n)
if (3.14)
if (-3.14)
if (Infinity)
if (-Infinity)