Skip to content

Instantly share code, notes, and snippets.

@gabrielrubens
Created November 4, 2014 13: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 gabrielrubens/01751f4ab2781d20ac0b to your computer and use it in GitHub Desktop.
Save gabrielrubens/01751f4ab2781d20ac0b to your computer and use it in GitHub Desktop.
Formatar String em JavaScript / Format String with JavaScript
stringFormat = 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