Nodejs String Padding Left lpad(padString, length)

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

Method Source Code

String.prototype.lpad = function(padString, length) {
  var str = this;
  while (str.length < length)
      str = padString + str;//from w w  w . j  a v  a 2 s.co m
  return str;
}

Related

  1. lpad(len, s)
    String.prototype.lpad = function(len, s) {   
        var a = new Array(this);   
        var n = (len - this.length);   
        for ( var i = 0; i < n; i++) {   
            a.unshift(s);   
        return a.join("");   
    };
    
  2. lpad(length, padString)
    String.prototype.lpad = function(length, padString){
        var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    };
    
  3. lpad(pSize, pCharPad)
    String.prototype.lpad = function(pSize, pCharPad)
      var str = this;
      var dif = pSize - str.length;
      var ch = String(pCharPad).charAt(0);
      for (; dif>0; dif--) str = ch + str;
      return (str);
    
  4. lpad(pad, length)
    function fill(num) {
        return (num == 10 ? '' : '0') + num;
    String.prototype.lpad = function(pad, length) {
        var s = this;
        while (s.length < length) {
            s = pad + s;
        return s;
    ...
    
  5. lpad(padLength, padString)
    String.prototype.lpad = function(padLength, padString){
        var s = this;
        while(s.length < padLength)
            s = padString + s;
        return s;
    
  6. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
      var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    
  7. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
        var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    
  8. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
        var str = this;
        while (str.length < length)
            str = padString + str;
        return str;
    };
    
  9. lpad(padString, length)
    String.prototype.lpad = function(padString, length) {
      var str = this;
      while (str.length < length) {
        str = padString + str;
      return str;
    };