| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Boolean/valueOf | [Back] [Original] |
Get to know MDN better
This feature is well established and works across many devices and browser versions. Its been available across browsers since July 2015.
The valueOf() method of Boolean values returns the primitive value of a
Boolean object.
const x = new Boolean();
console.log(x.valueOf());
// Expected output: false
const y = new Boolean("Mozilla");
console.log(y.valueOf());
// Expected output: true
valueOf()
None.
The primitive value of the given Boolean object.
The valueOf() method of Boolean returns the primitive value
of a Boolean object or literal Boolean as a Boolean data type.
This method is usually called internally by JavaScript and not explicitly in code.
valueOf()const x = new Boolean();
const myVar = x.valueOf(); // assigns false to myVar
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-boolean.prototype.valueof |
This page was last modified on Jul 10, 2025 by MDN contributors.
BooleanObject/FunctionYour blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |