Skip to main content

@rtorcato/js-common / boolean

boolean

Functions​

toBoolean()​

toBoolean(value): boolean

Defined in: boolean/index.ts:18

Converts a value to a boolean. Accepts 'true', '1', 1 as true; 'false', '0', 0 as false.

Example​

toBoolean('true') // true
toBoolean('0') // false
toBoolean(1) // true
toBoolean(2) // false
toBoolean(null) // false

Parameters​

value​

unknown

The value to convert.

Returns​

boolean

The boolean representation.