Monday, February 24, 2020

An in-depth tutorial on JavaScript Boolean Object with examples


Hello guys, evening and welcome to another section of my tutorial on JavaScript. In this tutorial post we are going to be discussing about JavaScript Boolean Object.

The Boolean object represents two values, either "true" or "false". If value parameter 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.No.Property & 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 tutorials, we will have a few examples to illustrate the properties of Boolean object.



Boolean Methods

Below is the list of the methods of Boolean object and their description.

Sr.No.Method & 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 tutorials, we will have a few examples to demonstrate the usage of the Boolean methods.

You can also read our tutorial post on: Html Header 

Alright guys we have come to the end of this tutorial on JavaScript Boolean Object. In our next tutorial, we will be using few examples to illustrate the properties of Boolean object.

Always feel free to ask your questions via the comment box below, and don't forget to follow us on our various social media platforms. Thanks for reading and bye for now.
Share:

0 comments:

Post a Comment