Nodejs String Padding Left lpad(padString, length)

Here you can find the source of lpad(padString, length)

Method Source Code

//pads left/*w  w  w  .jav a2  s . com*/
String.prototype.lpad = function(padString, length) {
   var str = this;
   //console.log(str.length+'-'+length)
    while (str.length < length){
        str = padString + str;
        //console.log(str)
    }
    return str;
}

Related

  1. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
        var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    
  2. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
        var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    };
    
  3. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
      var str = this;
      while (str.length < length) {
        str = padString + str;
      return str;
    };
    
  4. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
      var str = this;
      while(str.length < length)
        str = padString + str;
      return str;
    
  5. lpad(padString, length)
    "use strict";
    String.prototype.lpad = function(padString, length) {
      let str = this;
      while (str.length < length)
        str = padString + str;
      return str;
    };
    
  6. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
      var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    
  7. lpad(pad_str, length)
    String.prototype.lpad = function(pad_str, length) {
      var str = this;
      while (str.length < length) str = pad_str + str;
      return str;
    
  8. padL(width, pad)
    String.repeat = function(chr, count) {
      var str = "";
      for (var x = 0; x < count; x++) {
        str += chr;
      return str;
    };
    String.prototype.padL = function(width, pad) {
      if (!width || width < 1)
    ...
    
  9. padLeft( length, padding )
    Math.TO_DEGREES = 180 / Math.PI;
    Math.TO_RADIANS = Math.PI / 180;
    String.prototype.padLeft = function( length, padding )
        return Array( length - this.length + 1 ).join( padding || '0' ) + this;
    };