Allowing undefined as the NaN fallback in toInt
and toFloat
#71
aleclarson
announced in
RFCs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a minor gripe. Currently,
toInt
andtoFloat
return 0 if you don't provide your own NaN fallback value. Therefore, it's impossible to setundefined
as the fallback (it'll only be coerced to 0).This is only an issue when you'd like an
undefined
result (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
/toFloat
is the coercion of NaN to a less troublesome value.Beta Was this translation helpful? Give feedback.
All reactions