Here you can find the source of pad
/**/*ww w . j av a 2 s . c om*/ * @fileOverview This file contains new methods for the Number class */ /** * @name Number * @class A built-in class for numeric data which handles integers and floats within itself. */ /** * Return a padded string for the number. * * @param {Number} len The minimum length of the string to return * @param {String} [chars="0"] Characters to use when padding the number * @param [radix=10] The radix to use when turning the number into a string */ Number.prototype.pad = Number.prototype.padLeft = function pad(len, chars, radix) { return this.toString(radix || 10).padLeft(len || 0, chars || "0"); };
Number.prototype.pad = function($char, $length) { return (this + "").pad($char, $length);
Number.prototype.pad = function () { if ( this < 10 ) { return '0' + this; return this;
Number.prototype.pad = function() { var x = this.toString(); while(x.length < 2) { x = "0" + x; return x;
Number.prototype.pad = function(intPad) { if (this<0) { return "-" + (this-this*2).pad(intPad); var newThis = this.toString(); var reqPad = intPad - newThis.length; if (reqPad > 0) { return '0000000000000000'.substr(0,reqPad) + this; return newThis; };