JavaScript Boolean constructor Property
In JavaScript, the boolean constructor property returns the constructor function for an object.
Syntax:
boolean.constructor
Parameter: This method does not accept any parameter.
Return value: It returns the function Boolean() { [native code] }.
Below are examples of the Boolean constructor property.
Example 1:
javascript
var bool = false ; document.write( "bool.constructor:" + bool.constructor); |
Output:
bool.constructor:function Boolean() { [native code] }
Example 2: This example illustrates the boolean constructor property.
html
< body style = "text-align:center;" > < div > < h1 style = "color: green;" > GeeksforGeeks </ h1 > < p > JavaScript Boolean constructor Property returns the function that created the boolean's prototype: </ p > < b id = "GFG" ></ b > </ div > <!-- Script to use boolean constructor --> < script > var bool = false; document.getElementById("GFG").innerHTML = bool.constructor; </ script > </ body > |
Output:
Example 3: This example illustrates boolean constructor property.
html
< body style = "text-align:center;" > < div > < h1 style = "color: green;" >GeeksforGeeks</ h1 > < p > JavaScript Boolean constructor Property returns the function that created the boolean's prototype: </ p > < button onclick = "gfg()" >Click me</ button > < p id = "name" ></ p > </ div > <!-- Script to use Boolean constructor Property --> < script > function gfg(){ var bool = false; document.getElementById("name").innerHTML = bool.constructor; } </ script > </ body > |
Output:

JavaScript Boolean constructor Property
Supported Browsers: The browsers supported by JavaScript Boolean constructor Property are listed below:
- Google Chrome 1 and above
- Internet Explorer 3 and above
- Mozilla Firefox 1 and above
- Safari 1 and above
- Opera 4 and above
We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through Javascript Cheat Sheet-A Basic guide to JavaScript.
Please Login to comment...