toBool
Converts a value to a boolean.
Syntax
toBool(value)Arguments
value - The value to convert. Supported types and conversions:
bool - returned as-is
string -
"true","1","yes"becometrue;"false","0","no",""becomefalseint -
0isfalse, any other value istruefloat -
0isfalse, any other value istruenull - becomes
false
Examples
String conversions
toBool("true") // true
toBool("yes") // true
toBool("1") // true
toBool("false") // false
toBool("no") // false
toBool("0") // false
toBool("") // falseNumeric conversions
Null
CLI usage — convert a string flag to boolean
Last updated