Last active
November 26, 2019 01:49
-
-
Save dmwyatt/9550967 to your computer and use it in GitHub Desktop.
[String.format for javascript]
This file contains hidden or 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
| // From http://stackoverflow.com/questions/1038746/equivalent-of-string-format-in-jquery | |
| String.prototype.format = String.prototype.f = function() { | |
| var s = this, | |
| i = arguments.length; | |
| while (i--) { | |
| s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]); | |
| } | |
| return s; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment