Truthy and falsy values in JavaScript
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,0x0etc. - BigInt type:
0n,0x0n,0b0netc.
- Number type:
- Empty string value:
"",''and`` undefined,nullandNaN.
All the rest of the values in JavaScript are truthy values.