We now have a youtube channel. Subscribe!

An in-depth tutorial on JavaScript Boolean Object with examples



Hello readers! welcome back 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 the 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 our subsequent 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 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 our subsequent tutorials, we are going to have a few examples to demonstrate the usage of all the aboved listed Boolean methods.

You can also read our tutorial post on: Html Header

Alright guys! This is where we are rounding up for this tutorial post. In my next tutorial, we are going to be making use of few examples in demonstrating the usage of the Boolean Methods.

Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain