bool()

Converts argument to boolean.

Syntax

bool(value)

Parameters

Parameter Type Description
value Number/String/None Value to be evaluated.

Return Value

Examples

bool(5);      // returns 1
bool(true);      // returns 1
bool("true");      // returns 1
bool(nan());  // returns 0
bool("abc");  // returns 0
bool(none()); // returns 0

See also

is_none()
is_num()
is_str()
is_valid()
bool()