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.
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 |
---|---|
1 | constructor
Returns a reference to the Boolean function that created the object.
|
2 | prototype
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.
You can also read our tutorial post on: How to implement the various JavaScript Number methods with examples
Boolean Methods
Below is the list of the methods of Boolean object and description.
Sr.No. | Method & Description |
---|---|
1 | toSource()
Returns a string containing the source of the Boolean object; you can use this string to create an equivalent object.
|
2 | toString()
Returns a string of either "true" or "false" depending upon the value of the object.
|
3 | valueOf()
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.
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.