Skip to content

Instantly share code, notes, and snippets.

@gregdangelo
Created March 16, 2012 14:57
Show Gist options
  • Save gregdangelo/2050429 to your computer and use it in GitHub Desktop.
Save gregdangelo/2050429 to your computer and use it in GitHub Desktop.
JS padding integers
/*
src: http://jsconsole.com/?v%20%3D%204%3B%20'0'.substr(v%20%3C%2010%20%3F%200%20%3A%201)%20%2B%20v%3B
via @rem
*/
v = 4; '0'.substr(v < 10 ? 0 : 1) + v;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment