Skip to main content

Function: toBool()

toBool(value): boolean

Defined in: state/utils.ts:158

Converts a string or boolean value to a boolean.

String values are converted by checking if they equal the string "true". Boolean values are returned as-is.

Parameters​

value​

The value to convert (string or boolean)

string | boolean

Returns​

boolean

The boolean representation of the value

Example​

toBool("true"); // true
toBool("false"); // false
toBool(true); // true
toBool(false); // false
toBool("yes"); // false