Javascript Number pad()
Number.prototype.pad = function () { if ( this < 10 ) { return '0' + this; } return this;/*from w ww. ja v a 2 s.co m*/ }
"use strict";//from www. j a va2 s. c o m Number.prototype.pad = function() { var s = this.toString(); return (s.length < 4) ? ('000' + s).slice(-4) : s; }