Created
April 1, 2013 05:04
-
-
Save leafbird/5283316 to your computer and use it in GitHub Desktop.
string formatting function in JavaScript.
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.prototype.format = function () { | |
var formatted = this; | |
for (arg in arguments) { | |
formatted = formatted.replace("{" + arg + "}", arguments[arg]); | |
} | |
return formatted; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment