Skip to content

falsy

A falsy value is a value that JavaScript treats as false when it appears where a Boolean is expected, such as the condition of an if statement.

JavaScript has exactly eight falsy values: false, 0, -0, 0n, "", null, undefined, and NaN. Apart from one browser exception covered below, every other value is truthy, including the strings "0" and "false" and every empty array or object.

ECMA-262 fixes this list in ToBoolean, the abstract operation that converts any value to a Boolean. Conditions in if statements and loops rely on it, and so do the ! operator and Boolean() called as a function.

Falsy values often show up in default-value shortcuts. The || operator skips every falsy operand, so a default written with it also replaces real values such as 0 and "". The ?? operator falls back only for null and undefined.

In browsers, the legacy document.all object is also falsy, the only object that is. ECMA-262 allows this through an optional internal slot that web browsers implement.

Example

Say a media player reads saved settings where a volume of 0 means muted, and falls back to defaults for missing values:

Language: JavaScript
> const settings = { volume: 0, nickname: "" };
undefined

> settings.volume || 50
50
> settings.volume ?? 50
0

> settings.nickname || "Guest"
'Guest'

The muted volume is 0, which is falsy, so || treats it as missing and restores the default of 50. The ?? operator keeps 0 because it reacts only to null and undefined. The empty nickname is falsy too, so || swaps it for "Guest".

A developer flips a TRUE/FALSE lever on a clay ticket machine whose IF, ELSE IF, and ELSE chutes sort day-trip tickets into green, yellow, and red bins.

Course

Decisions in JavaScript

Teach your JavaScript programs to decide: run code only when a condition holds, choose one path with else if, combine conditions with &&, || and !, clean text with string methods, and check input safely before you use it.

basics js

For additional information on related topics, take a look at the following resources:

Have a question about this? Mentor AI can show you examples, compare related terms, and point you to tutorials.


By Leodanis Pozo Ramos • Updated Nov. 16, 2026