W3cubDocs

/JavaScript

Boolean.boolean

The Boolean() constructor is used to create Boolean objects.

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 compatibilityUpdate compatibility data on GitHub

Desktop
Chrome Edge Firefox Internet Explorer Opera Safari
Boolean() constructor 1 12 1 3 4 1
Mobile
Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Boolean() constructor 1 18 4 10.1 1 1.0
Server
Node.js
Boolean() constructor 0.1.100

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://wiki.developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean/Boolean