0% found this document useful (0 votes)
11 views

27 Boolean Object

The Boolean object is used to convert non-Boolean values to Boolean true or false values. It represents two possible values: true or false. The Boolean object can be created using the new Boolean() constructor, which will return true for any value except empty values, 0, null, empty strings, or false, which will return false. The document also provides a complete reference to all Boolean object properties and methods.

Uploaded by

BaneeIshaqueK
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

27 Boolean Object

The Boolean object is used to convert non-Boolean values to Boolean true or false values. It represents two possible values: true or false. The Boolean object can be created using the new Boolean() constructor, which will return true for any value except empty values, 0, null, empty strings, or false, which will return false. The document also provides a complete reference to all Boolean object properties and methods.

Uploaded by

BaneeIshaqueK
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

JavaScript Boolean Object

The Boolean object is used to convert a non-Boolean value to a Boolean value (true
or false).
Try it Yourself - Ea!ples
"hec# Boolean value
"hec# if a Boolean object is true or false.
"o!plete Boolean Object $eference
%or a co!plete reference of all the properties and !ethods that can be used &ith the Boolean
object' (o to our co!plete Boolean object reference.
The reference contains a brief description and ea!ples of use for each property and !ethod)
"reate a Boolean Object
The Boolean object represents t&o values* +true+ or +false+.
The follo&in( code creates a Boolean object called !yBoolean*
var myBoolean=new Boolean();
Note: ,f the Boolean object has no initial value or if it is -' --' null' ++' false' undefined' or .a.' the
object is set to false. Other&ise it is true (even &ith the strin( +false+))
/ll the follo&in( lines of code create Boolean objects &ith an initial value of false*
var myBoolean=new Boolean();
var myBoolean=new Boolean(0);
var myBoolean=new Boolean(null);
var myBoolean=new Boolean("");
var myBoolean=new Boolean(false);
var myBoolean=new Boolean(NaN);
/nd all the follo&in( lines of code create Boolean objects &ith an initial value of true*
var myBoolean=new Boolean(true);
var myBoolean=new Boolean("true");
var myBoolean=new Boolean("false");
var myBoolean=new Boolean("Richard");

You might also like