Below is the example of the Boolean constructor property.
- Example:
<script type ="text/javascript">varbool =false;document.write("bool.constructor:"+ bool.constructor);</script>chevron_rightfilter_none - 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.
<!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.
<!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
- Internet Explorer
- Mozilla Firefox
- Safari
- Opera
Recommended Posts:
- JavaScript Boolean prototype Constructor
- JavaScript Array constructor Property
- JavaScript Date constructor Property
- JavaScript String constructor Property
- JavaScript Object.prototype.constructor Property
- JavaScript Number constructor Property
- Sort an array of objects using Boolean property in JavaScript
- JavaScript Array prototype Constructor
- JavaScript | RegExp constructor
- JavaScript TypeError - "X" is not a constructor
- TypeScript | String Constructor Property
- JavaScript Boolean valueOf() Method
- JavaScript Boolean toString() Method
- JavaScript Boolean
- JavaScript | Convert a string to boolean
- Convert boolean result into number/integer in JavaScript
- JavaScript | Boolean and dataView Complete Reference
- How to generate a random boolean using JavaScript ?
- How to toggle a boolean using JavaScript ?
- Web DOMRect API | DOMRect() Constructor
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


