Here you can find the source of padWithDigits(n)
// Extend Number function Number.prototype.padWithDigits = function (n) { var txt = this.toString(); while(txt.length < n) { txt = '0' + txt; } /* w ww . j a va 2 s .c o m*/ return txt; };
Number.prototype.padLeft = function (base, chr) { var len = (String(base || 10).length - String(this).length) + 1; return len > 0 ? new Array(len).join(chr || '0') + this : this; };
Number.prototype.padLeft = function(base,chr) { var len = (String(base || 10).length - String(this).length)+1; return len > 0? new Array(len).join(chr || '0')+this : this; };
Number.prototype.padLeft = function(max, c) { return this.toString().padLeft(max, c || '0'); };
Number.prototype.padLeft = function(n, str) { return Array(n-String(this).length+1).join(str||'0')+this; };
Number.prototype.padRight = function(max, c) { return this.toString().padRight(max, c || '0'); };
Number.prototype.padZeros = function(n){ return this.toString().padZeros(n); };
Number.prototype.pad = function pad(length) { var str = '' + this; while (str.length < length) { str = '0' + str; return str; };
Number.prototype.LenWithZero = function(oCount) { var strText = this.toString(); while (strText.length < oCount) { strText = '0' + strText; return strText; };
Number.prototype.leadingZero = function(length) { return ('0'+this).slice(-length);