JavaScript Tutorial

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

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: