Skip to content

Instantly share code, notes, and snippets.

@niyazpk
Created December 11, 2011 17:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niyazpk/1461787 to your computer and use it in GitHub Desktop.
Save niyazpk/1461787 to your computer and use it in GitHub Desktop.
//Convert a Number to a String
str = num.toString()
str = String(num)
//Convert a String to a Number
num = Number(str);
num = +str;
num = parseInt(str, 10);
parseInt("12em") === 12 // stops at first non digit
parseInt("08") === 0 // because 8 is not octal
parseInt("08", 10) === 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment