I just found this little trick to zero pad numbers in Javascript. It is also applicable to padding with any character, not just zeros.
-
var n = 123
-
String("00000" + n).slice(-5); // returns 00123
-
("00000" + n).slice(-5); // returns 00123
-
(" " + n).slice(-5); // returns " 123" (with two spaces)
Found here.

Wow!! Amazing solution! Simple and clean!
Thanks. So helpful