Boolean() constructor
The Boolean()
constructor is used to create
Boolean
objects.
The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.
Syntax
new Boolean([value])
Parameters
value
Optional- The initial value of the
Boolean
object.
Examples
Creating
Boolean
objects with an initial value of false
var bNoParam = new Boolean();
var bZero = new Boolean(0);
var bNull = new Boolean(null);
var bEmptyString = new Boolean('');
var bfalse = new Boolean(false);
Creating
Boolean
objects with an initial value of true
var btrue = new Boolean(true);
var btrueString = new Boolean('true');
var bfalseString = new Boolean('false');
var bSuLin = new Boolean('Su Lin');
var bArrayProto = new Boolean([]);
var bObjProto = new Boolean({});
Specifications
Browser compatibility
BCD tables only load in the browser