Skip to content

Instantly share code, notes, and snippets.

@devarajchidambaram
Created October 4, 2018 05:06
Show Gist options
  • Save devarajchidambaram/4ef750b8463bbe9f19827d9b90d7d18e to your computer and use it in GitHub Desktop.
Save devarajchidambaram/4ef750b8463bbe9f19827d9b90d7d18e to your computer and use it in GitHub Desktop.
Parseint vs Number in js
/**
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