Created
October 4, 2018 05:06
-
-
Save devarajchidambaram/4ef750b8463bbe9f19827d9b90d7d18e to your computer and use it in GitHub Desktop.
Parseint vs Number in js
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
/** | |
parseInt("123hui") | |
returns 123 | |
Number("123hui") | |
returns NaN | |
parseInt("1.234334") | |
returns 1 | |
Number("1.234334") | |
returns 1.234334 | |
In other words parseInt() parses up to the first non-digit and returns whatever it had parsed. Number() wants to convert the entire string into a number, which can also be a float BTW | |
**/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment