Falsy values in Javascript
Falsy values are the values evaluated negative in the if condition.
Or exactly defined from ECMA specs, these values are evaluated as false
when converted to boolean
Or these values make Boolean
function return false
when being taken as a parameter.
The following values are considered falsy in Javascript. All other values are not.
- Boolean false:
false
- Zero number:
0
- Negative zero:
-0
- BigInt zero:
0n
-
null
undefined
- Empty string:
''
NaN
Reference: ECMA262.