Skip to content
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

Improve description of Number.isNaN() #28173

Closed
gevuong opened this issue Jul 25, 2023 · 3 comments
Closed

Improve description of Number.isNaN() #28173

gevuong opened this issue Jul 25, 2023 · 3 comments
Labels
closed: question A user misinterpretation or support question. No action required. Content:JS JavaScript docs

Comments

@gevuong
Copy link
Contributor

gevuong commented Jul 25, 2023

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN

What specific section or headline is this issue about?

The second part of the first sentence in the page.

What information was incorrect, unhelpful, or incomplete?

The first sentence states the following: The Number.isNaN() static method determines whether the passed value is the number value NaN, and returns false if the input is not of the Number type.

I think the second part of the sentence, and returns false if the input is not of the Number type, may be inaccurate (or confusing) because:

  1. NaN is considered a Number type when checking its type using typeof.
  2. Therefore, passing NaN as the input would return true, not false.

What did you expect to see?

I think I expected to see something like, The Number.isNaN() static method determines whether the passed value is the number value NaN, and returns false if the input is not NaN.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

@gevuong gevuong added the needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. label Jul 25, 2023
@github-actions github-actions bot added the Content:JS JavaScript docs label Jul 25, 2023
@Josh-Cena
Copy link
Member

The first half of the sentence already covers everything "The Number.isNaN() static method determines whether the passed value is the number value NaN". The second half is only added to distinguish from isNaN(), which may return true for non-number inputs. The current text is not wrong—it does return true only if the input is NaN; it always returns false if the input is non-number.

@Josh-Cena Josh-Cena closed this as not planned Won't fix, can't repro, duplicate, stale Jul 25, 2023
@Josh-Cena Josh-Cena added closed: question A user misinterpretation or support question. No action required. and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Jul 25, 2023
@gevuong
Copy link
Contributor Author

gevuong commented Jul 25, 2023

Oh right, I see. Sorry, I misunderstood the statement 😅

@gevuong
Copy link
Contributor Author

gevuong commented Jul 27, 2023

After reviewing it once more, I think I understand why I was confused.

I misunderstood the second half, and returns false if the input is not of the Number type, and thought Number.isNaN() returns false only if the input is a non-number type. But that's not true. An input can be a number type and still return false (ie. Number.isNaN(5)).

With your explanation of why the second half was added, to distinguish from isNaN() which can return true for non-number inputs, it made more sense. Thanks for the clarification.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
closed: question A user misinterpretation or support question. No action required. Content:JS JavaScript docs
Projects
None yet
Development

No branches or pull requests

2 participants