Skip to content

Instantly share code, notes, and snippets.

@mchambaud
Created September 23, 2013 17:08
Show Gist options
  • Save mchambaud/6673730 to your computer and use it in GitHub Desktop.
Save mchambaud/6673730 to your computer and use it in GitHub Desktop.
if (!String.prototype.padLeft) {
String.prototype.padLeft = function (length, str) {
str = str || ' ';
return this.length >= length
? this
: (new Array(Math.ceil((length - this.length) / str.length) + 1).join(str)).substr(0, (length - this.length)) + this;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment