Converts the given parameter to a boolean.
This is the same as doing Boolean(value) however, if the value is a string containing only whitespace, this function will consider that an empty string, and therefore return false.
Boolean(value)
value
false
bool("false"); // truebool("true"); // truebool(""); // falsebool(" "); // falsebool(false); // falsebool("null"); // truebool({}); // truebool("Hello World"); // truebool(wrap(null)); // falsebool(wrap('')); // true Copy
bool("false"); // truebool("true"); // truebool(""); // falsebool(" "); // falsebool(false); // falsebool("null"); // truebool({}); // truebool("Hello World"); // truebool(wrap(null)); // falsebool(wrap('')); // true
Converts the given parameter to a boolean.
This is the same as doing
Boolean(value)
however, if thevalue
is a string containing only whitespace, this function will consider that an empty string, and therefore returnfalse
.