JavaScript Tutorial

adplus-dvertising
Boolean In JavaScript
Previous Home Next

A JavaScript use Boolean to represents one of two values i.e true or false.

A boolean program which return true value.

Example :

<html>
<body>
<p>Display the value of 20 > 10</p>
<button onclick="myFunction()">button it</button>
<p id="demo"></p>
<script>
function myFunction() {
    document.getElementById("demo").innerHTML = 20 > 10;
}
</script>
</body>
</html>

Output :

true

A boolean program which return false value.

Example :


<html>
<body>
<p>Display the value of 20 > 50</p>
<button onclick="myFunction()">button</button>
<p id="demo"></p>
<script>
function myFunction() {
    document.getElementById("demo").innerHTML = 20 > 50;
}
</script>

</body>
</html>

Output :

false

Previous Home Next