Created
November 19, 2012 02:18
-
-
Save deholic/4108616 to your computer and use it in GitHub Desktop.
String.Format for prototype process
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.format = String.prototype.format = function() { | |
var i=0; | |
var string = (typeof(this) == "function" && !(i++)) ? arguments[0] : this; | |
for (; i < arguments.length; i++) | |
string = string.replace(/\{\d+?\}/, arguments[i]); | |
return string; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment