Skip to content

Instantly share code, notes, and snippets.

@srn
Created November 28, 2013 08:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srn/7688910 to your computer and use it in GitHub Desktop.
Save srn/7688910 to your computer and use it in GitHub Desktop.
String.prototype.format = function () {
var formatted = this;
for (var i = 0; i < arguments.length; i++) {
formatted = formatted.replace(
RegExp('\\{' + i + '\\}', 'g'), arguments[i]);
}
return formatted;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment