Boolean

JavaScript 1.1+, ECMAScript 1.0+, JScript 3.0+ Nav3+, NES3+, IE 4+ Syntax

var variable = new Boolean(value)
var variable = Boolean(value)

Description

The Boolean object is a wrapper object that holds a primitive Boolean value, as well as provides a method for converting the value to a string. A primitive boolean can have only one of two states: true or false. Internally, JavaScript uses the number 1 to represent true and 0 to represent false but provides the toString() method to return the strings "true" and "false".

A Boolean object is created with the Boolean() constructor and the new operator or by the Boolean() function. The argument, return value, and method associated with this object are listed in Table 6.19.

Table 6.19. ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.