Javascript Reference - JavaScript Boolean Reference

JavaScript booleans can have one of two values: true or false.

We can use the Boolean() function to find out if an expression is true.

<!DOCTYPE html>
<button onclick="myFunction()">test</button>
<p id="demo"></p>
<!--   w w  w. ja va2s  .  com-->
function myFunction() {
    document.getElementById("demo").innerHTML = Boolean(10 > 9);


The code above is rendered as follows:

Boolean Properties

Property Description
prototype Add properties and methods to the Boolean prototype

Boolean Methods

Method Description
toString() Converts a boolean value to a string
valueOf() Returns the primitive value of a boolean