Skip to content

Instantly share code, notes, and snippets.

@dmwyatt
Last active November 26, 2019 01:49
Show Gist options
  • Select an option

  • Save dmwyatt/9550967 to your computer and use it in GitHub Desktop.

Select an option

Save dmwyatt/9550967 to your computer and use it in GitHub Desktop.
[String.format for javascript]
// From http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery
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