JavaScript Boolean Object With Example

JavaScript Boolean Object

Boolean Object is a primitive data type in JavaScript. Boolean can have only two values, true or false.

Boolean Method:

Method Description
toLocaleString() Returns string of boolean value in local browser environment.

Example: var result = (1 > 2); result.toLocaleString(); // returns "false"
toString() Returns a string of Boolean.

Example: var result = (1 > 2); result.toString(); // returns "false"
valueOf() Returns the value of the Boolean object.

Example: var result = (1 > 2); result.valueOf(); // returns false


Read Also: