Skip to content

Boolean

The Boolean global object converts any value to a boolean primitive when it’s called as a function, and wraps a boolean in an object when it’s called with new. The primitive itself is the boolean type, and Boolean.prototype supplies the methods that every true and false value can call:

Language: JavaScript
> Boolean("yes")
true
> typeof Boolean(0)
'boolean'

> typeof new Boolean(0)
'object'

Boolean is an ECMAScript built-in. Calling it as a function is the common use. The conversion follows the same truthy and falsy rules that if conditions apply, so the full list of falsy values lives in the boolean entry.

Syntax

The Boolean function takes one optional value to convert:

Language: JavaScript Syntax
Boolean([<value>])
new Boolean([<value>])
Parameter Description
value An optional value of any type to convert. It defaults to undefined, which converts to false

Without the new keyword, the call returns a boolean primitive. With new, it returns a Boolean object that holds that primitive. The new keyword is optional, but it changes the result, so wrapper objects appear only where code asks for them.

Key Instance Methods and Properties

Boolean has no static methods. Its prototype holds three members, which primitives reach through a temporary wrapper:

Member Kind Description
.toString() Instance method Returns the string "true" or "false"
.valueOf() Instance method Returns the primitive boolean value that a Boolean object holds
.constructor Instance property Refers to the Boolean constructor

Examples

A tag field in a form can come back with empty strings and null entries. Passing Boolean as the callback to .filter() keeps only the truthy values:

Language: JavaScript
> const tags = ["js", "", "node", null, "web"];
undefined

> tags.filter(Boolean)
[ 'js', 'node', 'web' ]

A settings object needs to become a query string. Each flag is a primitive, but calling .toString() on it works because the method comes from Boolean.prototype:

Language: JavaScript
> const settings = { darkMode: true, beta: false };
undefined

> Object.entries(settings).map(
…   ([key, enabled]) => `${key}=${enabled.toString()}`,
… ).join("&")
'darkMode=true&beta=false'

> Object.getPrototypeOf(true) === Boolean.prototype
true

Older code sometimes stores flags as Boolean objects. The .valueOf() method unwraps one into the primitive that strict equality can compare:

Language: JavaScript
> const legacyFlag = new Boolean(false);
undefined

> legacyFlag === false
false
> legacyFlag.valueOf() === false
true

Common Gotchas

A Boolean object is truthy even when it holds false, because every object is truthy. A permission check that receives a wrapper instead of a primitive grants access:

Language: JavaScript
> const isAdmin = new Boolean(false);
undefined

> isAdmin ? "access granted" : "access denied"
'access granted'

Truthiness never calls .valueOf() on an object, so unwrapping happens only when code calls it directly.

Each new Boolean() call creates a separate object, and strict equality compares object identity, so two wrappers that hold the same value are never equal:

Language: JavaScript
> new Boolean(true) === new Boolean(true)
false
> new Boolean(true).valueOf() === new Boolean(true).valueOf()
true

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