Boolean() (Function)

A Boolean object constructor.

Availability:

ECMAScript edition - 2
JavaScript - 1.1
JScript - 3.0
Internet Explorer - 4.0
Netscape - 3.0
Property/method value type:Boolean primitive
JavaScript syntax:-Boolean()
-Boolean(aValue)
Argument list:aValueA value to be converted to a Boolean result.

When the Boolean() constructor is called as a function, it performs a type conversion on the value that is passed to it as a parameter.

The following results are yielded by the Boolean() constructor function:

Value:Result:
No valuefalse
undefinedfalse
nullfalse
Boolean falsefalse
Boolean truetrue
NaNfalse
0false
Non zero numbertrue
Zero length string ""false
Non zero length stringtrue
Objecttrue

The result will be true or false depending on the parameter's value. If the parameter value is omitted, then false is returned by default.

See also:Cast operator, Constructor function, constructor property, Implicit conversion, Type conversion

Cross-references:

ECMA 262 edition 2 - section - 15.1.3.5

ECMA 262 edition 2 - section - 15.6.1

ECMA 262 edition 2 - section - 15.6.2

ECMA 262 edition 2 - section - 15.6.3

ECMA 262 edition 3 - section - 15.6.1