Created
August 22, 2016 07:50
-
-
Save aloha1003/8e4b51da3ba1c323350a8c2266a37fe5 to your computer and use it in GitHub Desktop.
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; | |
}; | |
//UseAge | |
/* | |
var test= "Hello {0} @ {1}!!"; | |
test.format("John", "World); | |
will return Hello John @ World | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment