Wednesday, 25 August 2010

Javascript string.format


String.prototype.format = function () {
formatted = this;
for (i = 0; i < arguments.length; i++) {
formatted = formatted.replace("{" + i + "}", arguments[i]);
}
return formatted;
}