Skip to content

Instantly share code, notes, and snippets.

@rymoore99
Created March 1, 2014 12:19
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 rymoore99/9289003 to your computer and use it in GitHub Desktop.
Save rymoore99/9289003 to your computer and use it in GitHub Desktop.
JS String Format
if (!String.format) {
String.format = function(format) {
var args = Array.prototype.slice.call(arguments, 1);
return format.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