Below is the example of the Boolean prototype Constructor property.
// Creating a new boolean object
"Color of Gfg = "
Color of Gfg = Green
The Boolean prototype Constructor property is used to add a new property and methods to all Boolean instances. By the time of creating properties ALL booleans will be given the property, and it’s valued, as default but in case of methods, ALL booleans will have this method available.
Boolean.prototype.name = value
Here “name” specifies the property or method name to be used and “value” specifies the value used by the function.
Some methods related to Boolean.prototype property:
- Boolean.prototype.valueOf(): It simply returns the value of boolean object.
- Boolean.prototype.toString(): This method returns a string according to the Boolean value.
More example codes for the above constructor are as follows:
1 is True. 0 is False. myVar = false
Obj.CheckGeek(true) = Pro Geek Obj.CheckGeek(false) = Geek Obj.valueOf() = true Obj.toString() = true
- Google Chrome
- Internet Explorer
- Mozilla Firefox