Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

Boolean — conversion to a boolean value

Boolean(value) converts a value to primitive true or false using JavaScript's truthiness rules. It does not interpret the string "false" as false. Calling it with new creates an object rather than a primitive boolean.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

Boolean(value)
Boolean()
new Boolean(value)

Boolean(value) returns primitive true or false using the ToBoolean operation. Boolean() returns false. This is an ECMAScript built-in function, not a browser API.

Falsy values are false, undefined, null, 0, -0, NaN, 0n, and "". Other values are truthy, including "false", "0", [], and {}. A legacy web exception applies to objects with the [[IsHTMLDDA]] internal slot, which are falsy.

new Boolean(value) creates a wrapper object. Even new Boolean(false) is truthy during boolean conversion; typeof returns "object" for it. Use primitives, not wrapper objects, for ordinary flags. The wrapper's valueOf() method returns its stored boolean value.

Examples

console.log(Boolean());
console.log(Boolean(0));
console.log(Boolean("false"));
console.log(Boolean([]));
const wrapped = new Boolean(false);
console.log(typeof wrapped);
console.log(Boolean(wrapped));
console.log(wrapped.valueOf());

Result

false
false
true
true
object
true
false

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources