How to declare boolean variables in JavaScript?

JavascriptWeb DevelopmentFront End Technology

A boolean variable in JavaScript has two values True or False.

Example

You can try to run the following code to learn how to work with Boolean variables −

<!DOCTYPE html>
<html>
   <body>
      <p>35 > 20</p>
      <button onclick="myValue()">Click for result</button>
      <p id="test"></p>
      <script>
         function myValue() {
            document.getElementById("test").innerHTML = Boolean(35 > 20);
         }
      </script>
   </body>
</html>
raja
Published on 16-Jan-2018 11:04:52
Advertisements