O'Reilly logo

JavaScript Pocket Reference, 2nd Edition by David Flanagan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Boolean

Constructor

new Boolean(value)
Boolean(value)

Invoked as a function, without the new operator, Boolean( ) converts value to a boolean value (not a Boolean object) and returns it. All values convert to true except for 0, NaN, null, undefined, and the empty string, “”. When invoked with the new operator, the Boolean( ) constructor performs the same conversion and wraps the result in a Boolean object.

Methods

toString( )

Returns “true” or “false”, depending on the value of the Boolean object.

valueOf( )

Returns the primitive boolean value wrapped by the Boolean object.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required