Monday, July 9, 2018

JavaScript - The Boolean Object

JavaScript - The Boolean Object


Advertisements


The Boolean object represents two values, either "true" or "false". If valueparameter is omitted or is 0, -0, null, false, NaN, undefined, or the empty string (""), the object has an initial value of false.

Syntax

Use the following syntax to create a boolean object.
var val = new Boolean(value);

Boolean Properties

Here is a list of the properties of Boolean object −
Sr.NoProperty & Description
1constructor
Returns a reference to the Boolean function that created the object.
2prototype
The prototype property allows you to add properties and methods to an object.
In the following sections, we will have a few examples to illustrate the properties of Boolean object.

Boolean Methods

Here is a list of the methods of Boolean object and their description.
Sr.NoMethod & Description
1toSource()
Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
2toString()
Returns a string of either "true" or "false" depending upon the value of the object.
3valueOf()
Returns the primitive value of the Boolean object.
In the following sections, we will have a few examples to demonstrate the usage of the Boolean methods.

No comments:

Post a Comment