Created
May 16, 2011 22:28
-
-
Save fredrick/975520 to your computer and use it in GitHub Desktop.
Revisions
-
Fredrick Galoso created this gist
May 16, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ /* * Extend JavaScript String object with printf() like functionality * "{0} is dead, but {1} is alive!".format("This", "that"); */ String.prototype.format = function() { var formatted = this; for(arg in arguments) { formatted = formatted.replace("{" + arg + "}", arguments[arg]); } return formatted; };