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 −
<html> <head> <title>JavaScript Boolean</title> </head> <body> <script> var num1 = 10; var num2 = 20; document.write(num1 > num2); </script> </body> </html>