JavaScript Booleans

JavaScript booleans are a primitive data type that has either true or false values. It is mainly used in conditional statements such as if, if..else, switch, etc.

General Syntax
      var booleanVariable = true/false;
    
Try it now

Source Code

          
            var isDeveloper = true;
var isDesigner = false;          
        
Try it now

Boolean Constructor Function

The Boolean() constructor function is basically used to take input and convert it into a boolean value. It can also evaluate the javascript expression and provides results into a boolean value.

Let us understand it with the help of an example.

Source Code

          
            var isDeveloper = true;
var isDesigner = false;          
        
Try it now

Boolean As Object

When the Boolean() constructor function is invoked by a new operator then it generates new instances of the boolean object.

Source Code

          
            var isDeveloper = true; // boolean
var isDba = new Boolean(true); // object          
        
Try it now

Web Tutorials

Javascript Booleans
Html Tutorial HTML
Javascript Tutorial JAVASCRIPT
Css Tutorial CSS
Bootstrap 5 Tutorial BOOTSTRAP 5
Bootstrap 4 Tutorial BOOTSTRAP 4