Boolean.prototype.valueOf()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
ThevalueOf() method ofBoolean values returns the primitive value of aBoolean object.
In this article
Try it
const x = new Boolean();console.log(x.valueOf());// Expected output: falseconst y = new Boolean("Mozilla");console.log(y.valueOf());// Expected output: trueSyntax
js
valueOf()Parameters
None.
Return value
The primitive value of the givenBoolean object.
Description
ThevalueOf() method ofBoolean returns the primitive valueof aBoolean object or literalBoolean as a Boolean data type.
This method is usually called internally by JavaScript and not explicitly in code.
Examples
>UsingvalueOf()
js
const x = new Boolean();const myVar = x.valueOf(); // assigns false to myVarSpecifications
| Specification |
|---|
| ECMAScript® 2026 Language Specification> # sec-boolean.prototype.valueof> |