Nodejs Number Format Pad pad()

Here you can find the source of pad()

Method Source Code

Number.prototype.pad = function () {
   if ( this < 10 ) {
      return '0' + this;
   }/*from www.  j av a  2 s . c o m*/
   return this;
}

Related

  1. pad
    Number.prototype.pad =
    Number.prototype.padLeft = function pad(len, chars, radix) {
      return this.toString(radix || 10).padLeft(len || 0, chars || "0");
    };
    
  2. pad($char, $length)
    Number.prototype.pad = function($char, $length) {
        return (this + "").pad($char, $length);
    
  3. pad()
    Number.prototype.pad = function() {
        var x = this.toString();
        while(x.length < 2) {
            x = "0" + x;
        return x;
    
  4. pad(intPad)
    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;
    };
    
  5. pad(len)
    Number.prototype.pad = function (len) {
        return (new Array(len+1).join("0") + this).slice(-len);
    };
    
  6. pad(len)
    Number.prototype.pad = function(len) {
      s = num.toString();
      if (s.length < len) {
        s = ('00000000000000000000' + s).slice(-len);
      return s;
    };