parseInt can also operate on numbers.#15122
Closed
endel wants to merge 1 commit intomicrosoft:masterfrom
Closed
Conversation
`parseInt(3.5)` is a valid call on JavaScript and has a reasonable return value.
|
This seems like a small (but important) contribution, so no Contribution License Agreement is required at this point. We will now review your pull request. |
Member
|
Makes sense to me. @rbuckton what is your opinion? |
Member
|
Absolutely not! Don't use |
Contributor
|
I concur with @RyanCavanaugh, the MDN docs are promoting bad behavior in that example. Use |
Member
|
I've posted an edit to the MDN page |
Author
|
Thanks for the clarification and feedback, guys. I really appreciate that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Not sure if this has been reported already. I've searched in the closed issues and pull requests and couldn't find anything related.
parseInt(3.5)is a valid call on JavaScript and has a reasonable return value.Example:
Expected behaviour:
Output
3in the console.Actual behaviour:
You can see there's also some examples that provides numbers to
parseInton Mozilla's documentation: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/parseInt#Examples