toBoolean

[ Function ]

public static toBoolean(
    value: any,
    defaultValue: boolean | null = null
): boolean | null;

Converts any compatible value to a Boolean value.

Parameter

Name

Type

Description

value

any

The value to convert.

defaultValue

boolean, null

This value is returned if the first parameter cannot be converted. Null applies if this parameter is not passed.

Return value

Type

Description

boolean, null

Returns the Boolean value or null in the event of an error.

toBoolean 1:

Available from 1.8