var format = function(s, arg0) {
var args = arguments;
return s.replace(/\{(\d+)\}/ig, function(a, b) {
return args[(b | 0) + 1] || '';
});
};
console.log(format("{0} love {1}.",'I','You'));
转载于:https://www.cnblogs.com/liangxuru/p/4736945.html