Created
February 18, 2015 01:54
-
-
Save tyfkda/98974247176767089495 to your computer and use it in GitHub Desktop.
Convert string to number in JavaScript
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
| // Int string -> Number | |
| parseInt('123.456') // => 123 | |
| // Float string -> Number | |
| parseFloat('123.456') // => 123.456 | |
| // Any | |
| Number('123.456') // => 123.456 | |
| // Hex string -> Number | |
| parseInt('ffff', 16) // => 65536 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment