Created
January 7, 2014 19:02
-
-
Save dasjestyr/8304767 to your computer and use it in GitHub Desktop.
Javascript string extension for formatted strings
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
| 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