Javascript String padL(width, pad)
String.prototype.padL = function(width, pad) { if (!width || width < 1) return this;// w ww . j av a 2 s. co m if (!pad) pad = " "; var length = width - this.length; if (length < 1) return this.substr(0, width); return (String.repeat(pad, length) + this).substr(0, width); };