JavaScript Boolean constructor Property

JavascriptWeb DevelopmentObject Oriented Programming

The Boolean constructor property returns the constructor function that created the Boolean prototype −

Following is the code for JavaScript Boolean constructor property −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
   body {
      font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   }
</style>
</head>
<body>
<h1>JavaScript Boolean constructor Property</h1>
<p class="sample"></p>
<button class="btn">CLICK HERE</button>
<h3>Click on the above button to get the boolean constructor function</h3>
<script>
   var bool = true;
   document.querySelector(".btn").addEventListener("click", () => {
      document.querySelector(".sample").innerHTML =
      "The boolean constructor function: <br>" + bool.constructor;
   });
</script>
</body>
</html>

Output

On clicking the “CLICK HERE” button −

raja
Published on 07-May-2020 13:40:35
Advertisements