JS-037
Falsy explained in a JavaScript learning illustration — Behaves like false
Beginner4 min~4 min read#falsy#boolean#logic

Falsy

Behaves like false

Goal

Understand which values JavaScript treats as false in a Boolean context.

Explanation

  • Falsy values are values that become false when converted to Boolean.
  • JavaScript has a small set of falsy values.
  • The most common falsy values are false, 0, an empty string, null, undefined, and NaN.
  • In if statements, these values behave like false.
  • Understanding falsy values helps you write conditions correctly.

Analogy

Imagine a checkpoint. Falsy values do not pass the check and receive false status.

Code

console.log(Boolean(0));
console.log(Boolean(""));
console.log(Boolean(null));

Result: false false false

Common mistake

Beginners often think the string "false" is falsy. In fact, it is a non-empty string, so it is truthy.

Remember

  • Falsy values become false.
  • 0 is falsy.
  • An empty string is falsy.
  • null, undefined, and NaN are also falsy.

Quick Quiz

Which value is falsy?

Resources