Ad

Ad

Sunday, 4 May 2014

JavaScript Booleans

The Boolean object is used to convert a non-Boolean value to a Boolean value (true or false).

Examples

Try it Yourself - Examples

Check Boolean value
Check if a Boolean object is true or false.

Create a Boolean Object

The Boolean object represents two values: "true" or "false".
The following code creates a Boolean object called myBoolean:
var myBoolean=new Boolean();
If the Boolean object has no initial value, or if the passed value is one of the following:
  • 0
  • -0
  • null
  • ""
  • false
  • undefined
  • NaN
the object is set to false. For any other value it is set to true (even with the string "false")!

Complete Boolean Reference

For a complete reference, go to our Complete JavaScript Boolean Reference.
The reference contains descriptions and examples of all Boolean properties and methods.

No comments:

Post a Comment