Boolean (Boolean - JavaScript)

Creates a Boolean object.

Defined in

Boolean (Standard - JavaScript)

Syntax

Boolean()

Boolean(value:boolean)

Parameters Description
value A value that converts to true or false. Defaults to false.

Usage

The following values convert to true:
  • The literal true, a boolean variable whose value is true, or an expression that evaluates to true.
  • A string that is not empty.
  • A number other than 0 or -0.
The following values convert to false:
  • The literal false, a boolean variable whose value is false, or an expression that evaluates to false.
  • An empty string.
  • The number 0 or -0.
  • The literal undefined, null, or NaN, or a variable or expression with that value.

Examples

(1) This computed label displays true or false.
var F = new Boolean();
var T = new Boolean(true);
T.toString() + " or " + F.toString()
(2) This computed label also displays true or false.
var F = new Boolean(0);
var T = new Boolean(1);
T.toString() + " or " + F.toString()
(3) This computed label displays true if the value of the global variable width is greater than the value of the global variable length. The global variables are bound to numeric fields.
var b = new Boolean(
	sessionScope.width > sessionScope.height);
b.toString()