JavaScript Boolean constructor Property
Below is the example of the Boolean constructor property.
- Example:
javascript
<script type = "text/javascript" > var bool = false ; document.write( "bool.constructor:" + bool.constructor); </script> |
- Output:
bool.constructor:function Boolean() { [native code] }
In JavaScript, the boolean constructor property returns the constructor function for an object. For JavaScript Boolean, the constructor property returns function Boolean() { [native code] }.
Syntax:
boolean.constructor
Return value: It returns the function Boolean() { [native code] }.
More example codes for the above property are as follows:
Example 1: This example illustrates boolean constructor property.
html
<!DOCTYPE html> < html > < head > < title > JavaScript Boolean constructor Property </ title > </ head > < 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 > </ html > |
Output:
Example 2: This example illustrates boolean constructor property.
html
<!DOCTYPE html> < html > < head > < title > JavaScript Boolean constructor Property </ title > </ head > < 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 > </ html > |
Output:
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