JavaScript Boolean


JavaScript Boolean is an object that can have one of two values i.e. either true or false.

We can create a JavaScript Boolean object by the Boolean() constructor.

JavaScript treats 0, negative number (-10), false, empty string (“”), undefined, NULL, NaN as FALSE and everything else is TRUE.

The default value of JavaScript Boolean object is false.

Syntax:

    Boolean obj = new Boolean(value);


Example:

    Boolean(100 > 120); //FALSE
    Boolean(100 > 20); //TRUE