falsy
A value that counts as false in a condition: false, 0, -0, 0n, the empty string, null, undefined and NaN.
In more detail
The || operator treats every falsy value as missing, which is why ?? is safer for defaults. NaN means not a number.
Related terms
- truthy — A value that counts as true in a condition such as if (value), which is every value except the falsy ones.
- nullish coalescing — The double question mark operator (??), which gives a fallback value only when the left side is null or undefined.
Taught in
- The in Operator And Instanceof Narrowing — Production TypeScript