Skip to content

Instantly share code, notes, and snippets.

@dasjestyr
Created January 7, 2014 19:02
Show Gist options
  • Save dasjestyr/8304767 to your computer and use it in GitHub Desktop.
Save dasjestyr/8304767 to your computer and use it in GitHub Desktop.
Javascript string extension for formatted strings
String.prototype.format = String.prototype.f = function() {
var s = this,
i = arguments.length;
while (i--) {
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
}
return s;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment