Skip to content

Instantly share code, notes, and snippets.

@danilomiranda
Created December 15, 2017 15:23
Show Gist options
  • Save danilomiranda/f1d4901b9f986571d5b600316ff3e7f4 to your computer and use it in GitHub Desktop.
Save danilomiranda/f1d4901b9f986571d5b600316ff3e7f4 to your computer and use it in GitHub Desktop.
String.format = function (format, ...args) {
return format.replace(/{(\d+)}/g, ({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