JavaScript offers a special list of seven values known as falsy values. These values have the unique trait of always evaluating false
in a condition statement.
The following list explains how to identify falsy values:
0
BigInt 0n
null
undefined
false
NaN
""
(equivalent to ''
or ``)There are a few properties of falsy values to keep in mind:
0==0n==false==""
: The values 0
, 0n
, false
, and ""
are closely equal to each other. This means that if you write 0==false
in a condition, the condition will return true
.
null==undefined
: The null
and undefined
values are closely equal to each other. This means that if you write null==undefined
in a condition, the condition will return true
.
NaN
does not equal anything, not even itself.
Free Resources