Allowing undefined as the NaN fallback in toInt and toFloat
#71
aleclarson
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
This is a minor gripe. Currently,
toIntandtoFloatreturn 0 if you don't provide your own NaN fallback value. Therefore, it's impossible to setundefinedas the fallback (it'll only be coerced to 0).This is only an issue when you'd like an
undefinedresult (likely a rare occurrence, but in the name of elegance, I continue). To get that, you have to do this hideous workaround:I propose changing the default NaN fallback to
undefined. We may even prefer to remove the fallback argument entirely, since the primary benefit oftoInt/toFloatis the coercion of NaN to a less troublesome value.Beta Was this translation helpful? Give feedback.
All reactions