Inheritance diagram for Boolean:
Public Member Functions | |
Methods | |
String | toString () |
Number | valueOf () |
ECMAScript provides a Boolean data type that can have one of two primitive values, true or false. In general, creating objects of this type is not recommended since the behavior will probably not be what you would expect. Instead, assign the literal value true
or false
as required.
Any expression can be evaluated in a boolean context (e.g. in logical operations, such as conditionals). If the expression's value is 0, null, false
, NaN, undefined or an empty String, the expression is false
; otherwise the expression is true
.
var bOn = true; var bOff = false;
var nVal1 = 5; var nVal2 = 6; var bEqual = (nVal1 == nVal2); var bLessThan = (nVal1 < nVal2); var bGreaterThan = (nVal1 > nVal2);
String Boolean::toString | ( | ) |
Number Boolean::valueOf | ( | ) |