JavaScript Boolean

In JavaScripp Boolean objec is used to represents value in two states: true or false. In this tutorial Boolean method is explained.

Example of Boolean

In this example comparison is performed between two values. Answer will be true or false.

<script type = "text/javascript">

Output of above code

Example of Boolean constructor

You can create the JavaScript Boolean object by Boolean() constructor as given below.

<script type = "text/javascript">
Boolean b=new Boolean(value);  

JavaScript Boolean Properties

There are two boolean properties are given:

Property Description
constructor This property is used to returns the reference of Boolean function that created Boolean object.
prototype This property is used to enables you to add properties and methods in Boolean prototype.

JavaScript Boolean Methods

A list of boolean methods in JavaScript are give:

Method Description
toSource() This method is used to returns the source of Boolean object as a string in JavaScript.
toString() This method is used to converts Boolean into String in JavaScript.
valueOf() This method is used to converts other type into Boolean in JavaScript.

The Best

Comment here

If you have any query, if you want to know something about any of technical course related to computer science field, if you have any suggestion about relevant to uploaded content or if you anything wrong here (any mistake in content) than please contact us. Keep in mind, comment should be according to community guidelines.