-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
isNaN accept all types of arguments #3947
Conversation
Hi @dcharbonnier, I'm your friendly neighborhood Microsoft Pull Request Bot (You can call me MSBOT). Thanks for your contribution! TTYL, MSBOT; |
@@ -30,9 +30,9 @@ declare function parseFloat(string: string): number; | |||
|
|||
/** | |||
* Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). | |||
* @param number A numeric value. | |||
* @param number A numeric or a string value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"or string"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about booleans, as you originally wrote?
On one hand, I feel like this would fail to catch bugs, and if one really needs, they can always use a type guard (i.e. |
I'm struggling with utility of this. Other function like |
Reading more the ecmascript doc the argument is specified as Number. String is a 'free' implementation of the specs. |
No worries - always worth discussing! |
According to the ES5.1 specification, the Why check if a variable is a number before checking if it's not a number (NaN)? Why manually coerce a variable into a number before calling a function that, according to the specification, does just that? Edit: I just created issue #4002. |
According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN the argument can be a boolean, a string, a number or an object.