Skip to content

Instantly share code, notes, and snippets.

@samuelsimoes
Last active August 29, 2015 14:04
Show Gist options
  • Save samuelsimoes/f2b91d63a5b638f020e9 to your computer and use it in GitHub Desktop.
Save samuelsimoes/f2b91d63a5b638f020e9 to your computer and use it in GitHub Desktop.
// "{0} isso é um {1}".format('Olar', 'teste')
if (!String.prototype.format) {
String.prototype.format = function() {
var args = Array.prototype.slice.call(arguments);
return this.replace(/{(\d+)}/g, function(match, number) {
return (args[number] ? args[number] : match);
});
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment