JavaScript | Boolean constructor Property

In JavaScript, the 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] }.



Example 1: This example illustrates boolean constructor property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
  
<head>
    <title>
        JavaScript Boolean constructor Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <div style="background-color: green;">
              
        <h1>Welcome to GeeksforGeeks!.</h1>
                  
        <p>
            It returns the function that created
            the boolean's prototype:
        </p>
                  
        <h1 id="GFG"></h1>
          
    </div>
      
    <!-- Script to use boolean constructor -->
    <script>
        var bool = false;
        document.getElementById("GFG").innerHTML
                = bool.constructor;
    </script>
</body>
  
</html>                    

chevron_right


Output :

Example 2: This example illustrates boolean constructor property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
      
<head>
    <title>
        JavaScript Boolean constructor Property
    </title>
</head>
  
<body style="text-align:center;">
  
    <div style="background-color: white;">
          
        <h1>Welcome to GeeksforGeeks!.</h1>
          
        <h3>
            It returns the function that created
            the boolean's prototype:
        </h3>
          
        <p id="name" style="background-color: green;"></p>
    </div>
      
    <!-- Script to use Boolean constructor Property -->
    <script>
        var bool = false;
        document.getElementById("name").innerHTML
                = bool.constructor;
    </script>
</body>
  
</html>                    

chevron_right


Output:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.