Menu

JavaScript Truthy and Falsy Values: The Complete List

What counts as truthy and falsy in JavaScript, the full list of falsy values, and how boolean coercion plays out in real code.

Every Value Has a Boolean Mood

JavaScript lets you put any value where a boolean is expected — inside an if, as the condition of a while, next to && or ||. When you do, the value gets coerced to true or false. Values that coerce to false are called falsy. Everything else is truthy.

index.js
Output
Click Run to see the output here.

No conversion function, no explicit cast — JavaScript does it automatically. The rules are fixed and small, so once you know the falsy list, every other case follows.

The Complete Falsy List

Exactly seven values are falsy. Everything else in the language is truthy.

index.js
Output
Click Run to see the output here.

That's it. The list:

  • false — the boolean itself.
  • 0 and -0 — both zeros.
  • 0n — BigInt zero.
  • "" — the empty string (single, double, or backtick — all the same).
  • null — the "intentionally nothing" value.
  • undefined — the "not set" value.
  • NaN — the result of invalid math like 0 / 0.

Memorize these seven. Then for any value you're unsure about, ask: "is it one of those seven?" If not, it's truthy.

The Surprises: "0", [], and {}

This is where beginners get burned. Plenty of values look empty but are truthy:

index.js
Output
Click Run to see the output here.

Strings are falsy only when they have zero characters. "0" has one character, so it's truthy. Arrays and objects are always truthy — even empty ones — because JavaScript treats them as objects, and all objects are truthy regardless of what's inside.

If you're coming from Python, this is the biggest mental shift. In Python, [] and {} are falsy. In JavaScript, they are not.

Checking "Empty" the Right Way

Because [] and {} are truthy, you can't use them directly in an if to check for emptiness. Be explicit:

index.js
Output
Click Run to see the output here.

Same with strings, if you want to treat whitespace-only as empty:

index.js
Output
Click Run to see the output here.

Truthy/falsy is a convenient shorthand, not a replacement for thinking about what "empty" means for your data.

Converting to a Real Boolean

Sometimes you want an actual true or false, not just a truthy-ish value. Two idioms:

index.js
Output
Click Run to see the output here.

Boolean(x) is the explicit conversion. !!x is the same thing in shorthand — the first ! coerces to boolean and flips it, the second ! flips it back. Both are common. !! is shorter; Boolean() reads more clearly.

You'll often see !! in return statements where a function should return a clean boolean:

index.js
Output
Click Run to see the output here.

Truthy/Falsy With && and ||

The logical operators don't return true or false — they return one of the operands. Knowing which one depends on truthiness:

index.js
Output
Click Run to see the output here.

This is why value || defaultValue is such a common pattern for defaults. But it has a trap: it treats all falsy values the same, including 0 and "", which are often valid inputs:

index.js
Output
Click Run to see the output here.

If you only want to fall back on null or undefined, use the nullish coalescing operator ?? instead. That's covered in its own doc.

A Quick Reference

index.js
Output
Click Run to see the output here.

Print it out, tape it to your monitor, move on with your life.

Next: Iterators and Generators

With conditionals and loops under your belt, the next chapter looks at how JavaScript lets values produce themselves on demand. Iterators and generators are the machinery behind for...of, spread, and a lot of modern APIs — and they're up next.

Frequently Asked Questions

What are the falsy values in JavaScript?

There are exactly seven: false, 0, -0, 0n (BigInt zero), '' (empty string), null, undefined, and NaN. Everything else is truthy — including '0', 'false', [], and {}. Memorize the short falsy list and you know the answer for every other value by elimination.

Is an empty array truthy or falsy in JavaScript?

Truthy. if ([]) { ... } runs the block, which surprises people coming from Python or PHP. Arrays and objects are objects, and all objects are truthy regardless of contents. To check for an empty array, use arr.length === 0 explicitly.

How do I convert a value to a boolean in JavaScript?

Two ways: Boolean(value) is the explicit form, and !!value is the shorthand (a double negation that coerces then flips back). Both follow the same truthy/falsy rules. Use them when you want an actual true/false, not just a truthy-ish result.

Learn to code with Coddy

GET STARTED