Converts a String
or Number
to a Boolean
.
boolean()
converts values to true
or false
.
The parameter, n
, is the value to convert. If n
is a string, then boolean('true')
will return true
and every other string value will return false
. If n
is a number, then boolean(0)
will return false
and every other numeric value will return true
. If an array is passed, as in boolean([0, 1, 'true', 'blue'])
, then an array of Boolean values will be returned.
Examples
Syntax
boolean(n)
boolean(ns)
Parameters
n
String|Boolean|Number:
value to convert.
ns
Array:
values to convert.
Returns
Boolean: converted Boolean value.
Notice any errors or typos? Please let us know. Please feel free to edit src/utilities/conversion.js and open a pull request!