Skip to content

Instantly share code, notes, and snippets.

@hellraiser75
Created June 19, 2013 09:56
Show Gist options
  • Select an option

  • Save hellraiser75/5813156 to your computer and use it in GitHub Desktop.

Select an option

Save hellraiser75/5813156 to your computer and use it in GitHub Desktop.
string.prototype.format
if (!String.prototype.format) {
String.prototype.format = function () {
var args = arguments;
return this.replace(/{(\d+)}/g, function (match, number) {
return typeof args[number] != 'undefined'
? args[number]
: match
;
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment