How to declare a boolean in JavaScript?

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

var answer = true;


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

Live Demo

      <title>JavaScript Boolean</title>

         var num1 = 10;
         var num2 = 20;
         document.write(num1 > num2);

Updated on: 15-Jun-2020

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started