JavaScript Boolean Values and Truthiness
Quick answer
Boolean is a primitive type with exactly two values, true and false. Truthiness describes how a value is interpreted when a Boolean decision is required, rather than claiming that the value itself is a Boolean.
How it works
Boolean(value) returns the Boolean interpretation. False, undefined, null, positive and negative zero, 0n, NaN and the empty string are falsy. Ordinary objects are truthy even when empty; the browser legacy document.all is a special exception, not a normal object rule. The strings "false" and "0" are nonempty and truthy.
console.log(Boolean(""));console.log(Boolean("false"));Expected output in Node.js:
falsetrueConversion checks emptiness, not the spelling.
console.log(Boolean(0));console.log(Boolean(12));console.log(Boolean({}));Expected output in Node.js:
falsetruetrueAn empty ordinary object still has identity.
Common mistakes
Boolean("false") is not a text parser for a yes/no form. To interpret user-entered Boolean words, compare the accepted text explicitly; later lessons teach branching and validation. Avoid Boolean wrapper objects created with new Boolean.
Practice
Return the truthiness of a supplied primitive without returning the input itself.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
JavaScript Boolean Values and Truthiness — Knowledge Check
Apply the taught concept and reason about the result.
What does Boolean("false") return?
What does Boolean(0n) return?
What does Boolean({}) return for an ordinary empty object?
Which value is one of the two Boolean primitive values?
Why not parse a yes/no text field with Boolean(text)?