A Boolean object is a wrapper class and a member of global objects. It is used to convert non Boolean values into Boolean values. It has two values: true and false. The Boolean object returns false when the object is passed with values, such as, 0, “ ” (empty string), false, null, undefined and Not a Number (NAN) values. The Boolean object can be created in the following ways:
- Using Boolean literal notation.
- Using Boolean object as function.
- Using the testable expressions.
Demo
- Let us create a document named BooleanTest.html.
- Write the following code:
- Execute the script by Opening the file in the Web Browser. If you are using Internet Explore click on “Allow Blocked Content” to allow the script to execute and you are using Mozilla Firefox then click on allow “ActiveX Controls”.