booleans can have one of two values: true or false. - Javascript Boolean

Javascript examples for Boolean:constructor

Introduction

You can use the Boolean() function to find out if an expression is true:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {//  ww w .  jav  a  2s  .co m
    document.getElementById("demo").innerHTML = Boolean(10 > 9);
}
</script>

</body>
</html>

Or you can use the following

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

<script>
function myFunction() {/*from   w w w .  j av a 2 s .c om*/
    document.getElementById("demo").innerHTML = 10 > 9;
}
</script>

</body>
</html>

Related Tutorials