How to use JavaScript Boolean Constructor

In this article I have described about Boolean Constructor used in JavaScript.
  • 1915

JavaScript Boolean Constructor Property

  • As we know that Boolean object is used to convert the non Boolean value to Boolean value.
  • The Boolean object has a property named constructor property.
  • With the help of constructor Property we can create Boolean object's prototype

Browser support

Following are the main browsers which support the Constructor Property of Boolean object.

  • Internet Explorer.
  • Firefox.
  • Opera.
  • Google Chrome.
  • Safari.

Syntax

The Constructor Property of boolean object has following syntax

boolean.constructor

Lets take an example

<!DOCTYPE html>

<html>

<body style ="background-color:green">

<p id="menu">Dispay constructor of Boolean object</p>

<button onclick="myFunction()">Try it</button>

<script type="text/javascript">

    function myFunction() {

        var a = new Boolean(1);

        var x = document.getElementById("menu");

        x.innerHTML = a.constructor;

    }

</script>

 

</body>

</html>

 

Output

 

js boolean constructorimg.jpg

When we click on button

 js boolen cntrct img 2.jpg

Further Readings

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.