Truthy and Falsy Values in JavaScript the Complete List
JavaScript has eight falsy values, and everything else is truthy, including empty arrays, empty objects and the string zero. See the full list with a check.

Every if, every while and every && in JavaScript converts its operand to a boolean first, and the rule for the conversion fits on one line: there are eight falsy values and everything else is truthy. The rule is simple and the consequences are not, because the list contains 0 and the empty string, which are valid data in many programs, and omits [] and {}, which look empty. This post is the list, a runnable check for it and the places the list causes bugs. It is built on the seven primitive types, and the full conversion story is in how type coercion works. Examples run on Node.js 24.
The list
These are the eight values that convert to false, shown through Boolean().
const falsy = [false, 0, -0, 0n, "", null, undefined, NaN];
for (const value of falsy) {
console.log(String(typeof value).padEnd(9), Boolean(value));
}boolean false
number false
number false
bigint false
string false
object false
undefined false
number falseEach of the eight printed false. The object row is null, which reports its type as "object", a quirk covered in the post on typeof. In browsers there is a ninth exception, document.all, a legacy object that is falsy for compatibility, and no code written today should touch it.
| Value | Type | Why it is falsy |
|---|---|---|
false | boolean | It is the false value |
0 and -0 | number | Zero, either sign |
0n | bigint | Zero as a bigint |
"" | string | The empty string |
null | null | Deliberately empty |
undefined | undefined | Missing |
NaN | number | An invalid number |
Memorizing a reason for each is optional. Memorize the list of eight, and treat everything else as truthy.
The truthy values that surprise people
The values people expect to be falsy and are not are the reason the list is worth reading twice.
const surprising = [[], {}, "0", "false", " ", new Boolean(false), -1, Infinity, () => {}];
for (const value of surprising) {
console.log(Boolean(value));
}true
true
true
true
true
true
true
true
trueAn empty array and an empty object are objects, and every object is truthy. The strings "0" and "false" are non-empty strings, so they are truthy, and so is a string holding one space. new Boolean(false) is a wrapper object, and objects are truthy whatever they wrap, which is one reason to never construct a Boolean with new. A negative number and Infinity are not zero, and a function is an object.
The consequence is that an emptiness check needs an explicit test.
const items = [];
const settings = {};
console.log(items.length === 0);
console.log(Object.keys(settings).length === 0);
if (items) {
console.log("an empty array is still truthy");
}true
true
an empty array is still truthyCode that guards with if (items) and expects it to skip an empty list will run the branch every time. Check the length.
Where conditions use the list
Every operator that branches on a value uses it: if, while, the ?: conditional, !, &&, || and ?? is the exception, which tests only for null and undefined. The logical operators are worth a closer look, because they return an operand and not a boolean.
console.log(0 || "fallback");
console.log("" || null || "last");
console.log(5 && "second");
console.log(0 && "never reached");
console.log("kept" ?? "unused");
console.log(0 ?? "unused");fallback
last
second
0
kept
0|| returns the first truthy operand, or the last one if none qualifies. && returns the first falsy operand, or the last if all are truthy. And ?? replaces only null and undefined, so 0 ?? "unused" returns 0. That is the whole difference between the operators, and the post on nullish coalescing versus logical OR works through it.
The default value bug
Using || for a default is the most common truthiness bug. It treats every falsy value as missing, including the legitimate ones.
function createPager(options) {
const pageSize = options.pageSize || 20;
const showTotal = options.showTotal || true;
return { pageSize, showTotal };
}
console.log(createPager({ pageSize: 0, showTotal: false }));{ pageSize: 20, showTotal: true }The caller passed 0 and false, and both were replaced. The showTotal line is the nastier one, because || true can never produce false, so the option is permanently on. The fix is ??, which replaces only a missing value.
function createPager(options) {
const pageSize = options.pageSize ?? 20;
const showTotal = options.showTotal ?? true;
return { pageSize, showTotal };
}
console.log(createPager({ pageSize: 0, showTotal: false }));
console.log(createPager({}));{ pageSize: 0, showTotal: false }
{ pageSize: 20, showTotal: true }Now 0 and false are respected, and a missing option still gets its default. We changed this pattern in every options object we maintain, and it removed a class of "the setting does not stick" reports.
The rendering variant
A close cousin shows up in UI code that uses && to render conditionally. When the left side is a number, a zero is falsy and && returns it.
const count = 0;
console.log(count && "items");
console.log(count > 0 && "items");
console.log(Boolean(count) && "items");0
false
falseIn a JSX expression like {count && <List />}, the first form renders the number 0 on the page, a bug that has shipped in many apps. Compare with a boolean, count > 0, so the left operand is false and renders nothing.
Truthiness is not equality
A value can be truthy and still loosely equal to false, because == follows a different set of rules and does not call Boolean().
console.log(Boolean([]));
console.log([] == false);
console.log(Boolean("0"));
console.log("0" == false);true
true
true
trueAn empty array is truthy and also == false, because == converts both sides to numbers and the empty array becomes 0. Never compare a value with true or false loosely. Test truthiness with the value alone, if (value), or compare strictly. The post on == versus === covers the algorithm.
Reading a table of conditions
When a condition fails and you cannot see why, printing the operand's truthiness next to its value narrows it fast. A small helper that prints both beats a debugger for this, since the answer is one line per value.
function inspect(label, value) {
console.log(label.padEnd(14), JSON.stringify(value) ?? String(value), "=>", Boolean(value));
}
inspect("empty string", "");
inspect("zero string", "0");
inspect("empty array", []);
inspect("empty object", {});
inspect("undefined", undefined);
inspect("negative zero", -0);empty string "" => false
zero string "0" => true
empty array [] => true
empty object {} => true
undefined undefined => false
negative zero 0 => falseTwo lines need a note. JSON.stringify(undefined) returns undefined, so the helper falls back to String(value) through ??. And JSON.stringify(-0) prints 0, which hides the sign, so the label carries that information. A real program would not use this helper; it exists to show that -0 is falsy even though it looks like a zero you already know, and that "0", a string holding a zero, is the opposite.
The cases that fail in production are the ones from external data: a form field that arrives as "0", an API that returns [] for "no results" and a flag that arrives as the string "false". All three are truthy. Convert at the boundary: value === "true" for the flag, Number(text) for the count, and a length check for the list.
Lint rules that catch the common mistakes
Two ESLint rules cover most of the bugs above. @typescript-eslint/strict-boolean-expressions flags a condition whose operand is not a boolean, which stops if (items) on an array and count && <List /> with a number, and forces the explicit comparison. @typescript-eslint/prefer-nullish-coalescing flags || where ?? would be correct for a nullable operand. The first is strict enough that teams often enable it with options that allow nullable objects, and tune from there. Both rules need type information, so they run slower than syntax-only rules, and the slowdown is worth it on a codebase that has already shipped a 0 to a page. Turn them on for new code first, and fix the old violations in the files you touch, so the rule does not block a release on day one.
Where truthiness checks are the wrong tool
Use an explicit comparison whenever zero, an empty string or false is a legal input: counters, prices, flags, optional text. Use ?? for defaults. Reserve a bare if (value) for values where every falsy case really means "nothing to do", such as a nullable object reference or the result of a find().
When validating input from a form or a request, treat the empty string as a separate case from undefined, because they mean different things to the user, and merge them only after deciding what each should do.
The conversion is defined in the specification as ToBoolean, and MDN's Falsy and Truthy glossary pages list the values.


