javascript 仿 C# format

String.prototype.format = function() {
        var args = arguments;
        return this.replace(/{(d+)}/g, function(g0, g1) {
            return args[+g1];
        });

}

"hello {0},{0}'s age is {1}".format("tom",12)
原文地址:https://www.cnblogs.com/jh1994/p/5394875.html