Skip to content

Instantly share code, notes, and snippets.

@pid
Created February 8, 2014 14:13
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 pid/8884370 to your computer and use it in GitHub Desktop.
Save pid/8884370 to your computer and use it in GitHub Desktop.
helper: convert value/string to an integer // don't use parseInt( n , 10)
function toInteger(n) {
n = Number(n);
return n < 0 ? Math.ceil(n) : Math.floor(n);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment