Javascript String padLeft(pad, len)

Description

Javascript String padLeft(pad, len)


String.prototype.padLeft = function (pad, len)
{

 if (typeof(len) == "undefined") { var len = 0; }
 if (typeof(pad) == "undefined") { var pad = ' '; }

 if (len + 1 >= this.length)
 {
     str = Array(len + 1 - this.length).join(pad) + this;

 } // switch//from  w w  w  .j a  va 2  s.  c o m

    return str;
}



PreviousNext

Related