Truthy values are considered as true
and falsy values are considered as false
in Boolean contexts for example in conditionals and logical operators.
There are only the following falsy values in JavaScript:
- The Boolean false value:
false
- The zero value of both Number and BigInt type:
- Number type:
0
,-0
,0.0
,00
,0x0
etc. - BigInt type:
0n
,0x0n
,0b0n
etc.
- Number type:
- Empty string value:
""
,''
and``
-
undefined
,null
andNaN
.
All the rest of the values in JavaScript are truthy values.
That's it. Thanks for reading! Let's connect on Twitter.
Top comments (0)