In JavaScript, the Boolean object is a wrapper for the Boolean data type. The Boolean object is commonly used to convert a non-Boolean value to a Boolean value. The Boolean object represents two values, either true or false. The following example creates a Boolean object.

var myB = new Boolean();

If the Boolean object has no initial value, or if the passed value is one of the following values, the Boolean object returns false. Any other value passed to the Boolean Object will return true.

  • 0-0null"“falseundefinedNaN

Here are some examples of how to use the Boolean object. You can copy and paste this code into the HTML editor to try it yourself.

Always keep in mind that JavaScript is case-sensitive.