How to declare a boolean in JavaScript?

JavascriptWeb DevelopmentFront End Technology

To declare a Boolean in JavaScript, you need to assign true or false value.

var answer = true;

Example

To learn about the working of Boolean, let’s see the following example −

Live Demo

<html>
   <head>
      <title>JavaScript Boolean</title>
   </head>

   <body>
      <script>
         var num1 = 10;
         var num2 = 20;
         document.write(num1 > num2);
      </script>
   </body>
</html>
raja
Published on 18-Jan-2018 12:01:47
Advertisements