boolean
In JavaScript, boolean is a primitive type that has exactly two values, true and false, which represent the result of a logical test. It’s one of JavaScript’s primitive types, distinct from the Boolean wrapper object, whose prototype supplies its methods:
> true
true
> 3 > 2
true
> typeof false
'boolean'
Booleans are immutable and compare by value, so true === true is always true. Comparison operators such as > and ===, and the logical NOT operator !, always produce a boolean.
boolean Literals and typeof
The only boolean literals are the reserved words true and false. They’re lowercase, so True and FALSE are ordinary identifiers. The typeof operator reports 'boolean' for both literals and for the result of any comparison:
> typeof true
'boolean'
> typeof (1 === 1)
'boolean'
> typeof "true"
'string'
Converting to boolean
Boolean(value) converts explicitly, and a double NOT, !!value, does the same conversion. Both follow the type coercion rule that conditions such as if and while apply implicitly. A value that converts to true is truthy, and one that converts to false is falsy:
> Boolean("hello")
true
> !!0
false
> Boolean([])
true
> Boolean()
false
The falsy values are false, 0, -0, 0n, "", null, undefined, and NaN. Every other value is truthy, including every object, every symbol, and every non-empty string:
> [false, 0, -0, 0n, "", null, undefined, NaN].map(Boolean)
[
false, false,
false, false,
false, false,
false, false
]
Browsers add one legacy exception: document.all is falsy, through a special case that ECMA-262 defines in its Annex B for compatibility with old code.
Common boolean Gotchas
A Boolean wrapper object is truthy even when it wraps false, because every object is truthy:
> Boolean(new Boolean(false))
true
> new Boolean(false) ? "truthy" : "falsy"
'truthy'
Any non-empty string is truthy, including "false" and "0", so converting from input or environment variables with Boolean() doesn’t parse them:
> Boolean("false")
true
> Boolean("0")
true
Loose equality with a boolean operand converts that operand to a number instead of testing truthiness, so a truthy value can still equal false:
> [] == false
true
> "0" == false
true
> null == false
false
The value null is falsy, but it loosely equals only null and undefined, so null == false is false.
Arithmetic converts true to 1 and false to 0, so true + true evaluates to 2, a number rather than a boolean.
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. 4, 2026