Skip to content

Function: toBoolean()

toBoolean(value): boolean | undefined

Coerce a loose boolean-ish value to a real boolean, or undefined when it can’t be interpreted. Recognizes true/t/on/1/yes/y and their negatives (case- and whitespace-insensitive for strings), as well as the numbers 1 and 0.

unknown

boolean | undefined