Boolean Data Type in JavaScript

The blog provides the details on the usage of JavaScript Boolean Data Type. The Boolean Data Type returns “true” or “false” based on the validation of the given condition

Boolean properties in JavaScript

PropertyDescription
constructorWhen used in constructor, it returns the reference of
Boolean function that created Boolean object.
prototypeallows the developer enables you to add properties and
methods in Boolean prototype.

Boolean Methods in JavaScript

MethodDescription
toSource()The method returns the source of Boolean object as a string.
toString()The method converts Boolean value into String.
valueOf()The method converts other data type into Boolean.

Boolean Syntax in JavaScript

Boolean flag =new Boolean(value);  

JavaScript Boolean Data Type Example

 <script>  
 var a =999;
 var b =998;
document.write(a<b);//returns false boolean value    
document.write(a> b);//returns true boolean value  
</script>