Parses the string argument as a boolean. The boolean returned represents the value true if the string argument is not null and is equal, ignoring case, to the string "true".
When the Boolean.parse function is called with a string argument the following steps are taken:
- If Type(string) is not
"string"- Return
false
- Return
- Let normalizedString be the result of applying
String.prototype.toLowerCaseon the string - If normalizedString is
"true"- Return
true
- Return
- Return
false
Boolean.parse('true'); // true
Boolean.parse('false'); // false
// In contrast with problematic:
Boolean('false'); // trueStorages which doesn't support actual boolean values at serialization, and only have string-based value types. Example: Node's env arguments.
Examples are still using
parseBooleaninstead ofparse