ToBoolean (Operator/internal)

An internal operator for converting values.

Availability:

ECMAScript edition - 2

This internal operator converts the public types to Boolean values.

The ToBoolean operator converts its argument to a value of type Boolean according to the following table:

Input TypeResult
UndefinedAlways false.
NullAlways false.
BooleanNo conversion, the input value is returned unchanged.
NumberThe result is false if the argument is 0 or NaN otherwise it is true.
StringZero length strings return false otherwise the result is true.
ObjectAlways true.

See also:Cast operator, Conversion, Implicit conversion, Logical operator, Number, Type conversion

Property attributes:

Internal.

Cross-references:

ECMA 262 edition 2 - section - 9.2

ECMA 262 edition 3 - section - 9.2