Created
December 15, 2017 15:23
-
-
Save danilomiranda/f1d4901b9f986571d5b600316ff3e7f4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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