For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /reference/conversion/toBoolean.md.

toBoolean

Converts a value to a boolean.

Thin wrapper over Boolean(value) — kept as a stable surface against future global-constructor changes.

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

Usage

toBoolean(value: unknown)

Converts a value to a boolean.

Thin wrapper over Boolean(value) — kept as a stable surface against future global-constructor changes.

import { toBoolean } from 'massaman'
// or:  import { toBoolean } from 'massaman/conversion'

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

Parameters

valueunknownrequired

the value to convert.

Returns

the input value converted using JavaScript boolean coercion.

boolean