Javascript.Boolean


A true/false value used for Boolean algebra and representing and manipulating conditional values.

Javascript provides two types to represent true and false values: the boolean primitive value, and the Boolean object wrapper, the former providing potential performance improvements, the latter provides "everything is an object" compatibility.

Basic example:

Assigning primitive boolean values:

  var cheap = true;
  var fast = true;
  var good = false;

Comparing primitive boolean values and running conditional code based on the evaluation:

  var hasLicense = false;
  if (!hasLicense)
  {
     alert("Illegal breathing!");
  }

Here we use the Boolean wrapper object, assigning it a false value and then assigning the objects' primitive value to another variable:

  var isLoaded = new Boolean(false);
  var isReady = isLoaded.valueOf();

See also


This is part of the SpineFORGE Reference Documentation for Javascript?