A falsy (sometimes written falsey) value is a value that is considered false when encountered in a Boolean context.
JavaScript uses type conversion to coerce any value to a Boolean in contexts that require it, such as conditionals and loops.
The following table provides a complete list of JavaScript falsy values:Value Type Description null Null The keyword null — the absence of any value.undefined Undefined undefined — the primitive value.falseBoolean The keyword false.NaN Number NaN — not a number.0Number The Number zero, also including 0.0, 0x0, etc.-0Number The Number negative zero, also including -0.0, -0x0, etc.0nBigInt The BigInt zero, also including 0x0n, etc. Note that there is no BigInt negative zero — the negation of 0n is 0n.""String Empty string value, also including '' and ``.document.allObject The only falsy object in JavaScript is the built-in document.all.
The values null and undefined are also nullish.
Examples of falsy values in JavaScript (which are coerced to false in Boolean contexts, and thus bypass the if block):
if (false) {
// Not reachable
}
if (null) {
// Not reachable
}
if (undefined) {
// Not reachable
}
if (0) {
// Not reachable
}
if (-0) {
// Not reachable
}
if (0n) {
// Not reachable
}
if (NaN) {
// Not reachable
}
if ("") {
// Not reachable
}If the first object is falsy, it returns that object:
console.log(false && "dog");
// ↪ false
console.log(0 && "dog");
// ↪ 0