Pad a given number with leading zeroes. Useful to make it a fixed width like with e.g. sprintf
in other programming langages.
- Example:
00001
,00012
,00123
,01234
,12345
pad(number, count);
// returns number with leading zeros
See the 140byt.es site for a showcase of entries (built itself using 140-byte entries!), and follow @140bytes on Twitter. And check my "JavaScript Golf Lessons" slides.
JEDは、先生です!If we limit the count to 9 it would save an extra byte
a+1e9+""
- but 15 places are more flexible.BTW: Why does it not work with
1e16
?Can you point me to some resources with all the JS math limit stuff?