truthy
A truthy value is any value that JavaScript treats as true when it appears where a Boolean is expected, such as the condition of an if statement.
Only eight values aren’t truthy: false, 0, -0, 0n, "", null, undefined, and NaN. These are the falsy values, and every other value counts as truthy. That includes every object and array, even empty ones, and every non-empty string, even "0" and "false".
ECMA-262 defines the split through ToBoolean, the abstract operation that converts any value to a Boolean. Conditions in if and while statements use it, and so does the conditional operator. Calling Boolean() as a function or writing !!value returns the result directly.
The && and || operators also test truthiness, but they return one of their operands instead of a Boolean. ToBoolean never calls a method on the value, so an object is truthy even when its .valueOf() returns 0. In browsers, the legacy document.all object is the only falsy object.
Example
Say a shop shows a badge only when the cart has items, and reads an order quantity from a form field as a string:
> const cartItems = [];
undefined
> cartItems ? "Show badge" : "Hide badge"
'Show badge'
> cartItems.length ? "Show badge" : "Hide badge"
'Hide badge'
> const quantity = "0";
undefined
> Boolean(quantity)
true
> Boolean(Number(quantity))
false
The empty array is an object, so it’s truthy, and the badge appears for an empty cart. Testing .length turns the check into a number, and 0 is falsy. The quantity "0" is a non-empty string, so it stays truthy until it’s converted to the number 0.
Related Resources
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.
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