UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ Boolean/ Boolean.prototype.valueOf()

The valueOf() method of Boolean values returns the primitive value of a Boolean object.

Syntax

valueOf()

Parameters

None.

Return value

The primitive value of the given Boolean object.

Description

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.

Examples

Using valueOf()

x = new Boolean();
myVar = x.valueOf(); // assigns false to myVar

Specifications

Browser compatibility

See also