Course contentsShow
← JavaScript
Lesson 195 of 2,7236. Booleans and ConditionalsFree lesson

Truthy Values: What Evaluates to True

Identifying values that are considered true in Boolean contexts: non-zero numbers, non-empty strings, objects, etc.

Truthy Values: What Evaluates to True

You'll learn which values JavaScript automatically treats as "true" in conditional situations, even when they're not the literal boolean true.

What Are Truthy Values?

In JavaScript, truthy values are any values that JavaScript considers "true enough" when used in a boolean context (like an if statement or with the Boolean() constructor). Most values in JavaScript are truthy—it's actually easier to remember what isn't truthy.

Think of it like a bouncer at a club: most people get in (truthy), but a small list of specific cases get turned away (falsy). JavaScript assumes "yes" unless given a clear "no."

Common Truthy Values

Here are values that evaluate to true:

  • Non-zero numbers: 1, -5, 3.14, Infinity
  • Non-empty strings: "hello", "0", " " (even a space!)
  • Objects: {}, [] (even empty objects and arrays!)
  • The literal true (obviously!)
  • BigInt non-zero values: 1n, -5n

See It In Action

Boolean(42);           // true (non-zero number)
Boolean("hello");      // true (non-empty string)
Boolean(" ");          // true (string with space)
Boolean({});           // true (empty object)
Boolean([]);           // true (empty array)

// In conditional contexts
if ("something") {
    // This runs! Non-empty strings are truthy
}

if (100) {
    // This runs! Non-zero numbers are truthy
}

Notice that "0" (the string) is truthy, but 0 (the number) is falsy—a common gotcha!

Key Takeaway: Most JavaScript values are truthy—anything that isn't explicitly falsy (like 0, "", null, undefined, NaN, or false) will be treated as true in boolean contexts.