-
Notifications
You must be signed in to change notification settings - Fork 26.8k
Boolean("false") parses to true #531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
That's not for parsing a value - that's for coercing a value. Parsing a string into a boolean is an undefined operation - you need to implement it yourself. If you want the truthy value that is the string "false" to coerce to |
Thanks for the clarification, after looking at the example again I see the difference. |
Hi @tuhlmann, to follow up, just because I was typing this as this closed 😄 This is expected behavior as defined in #15.2
We use the Comparison Operators & Equality to outline the behavior of the 🍻 |
@hshoff Thanks for the clarification. For a seasoned Java developer Boolean(something) looks awefully familiar. In Java I guess that's where the confusion came from. Maybe a short note in this section would avoid this trap, saying this does not parse, but coerce... |
In section "21.6 Booleans" you advice to use
Boolean(x)
to parse a value into a boolean.Please note that parsing mostly any String results in
true
:null, undefined and ""
parse tofalse
.The text was updated successfully, but these errors were encountered: