string.format para javascript

Código:

String.prototype.format = function() {
var str = this;
for (var i = 0; i <= arguments.length - 1; i++) {
var reg = new RegExp("\{" + i + "\}", "gm");
str
= str.replace(reg, arguments[i]);
}
return str;
};

Uso:

console.log("Hello, {0}, today is {1}!".format("Tom", "Monday"));