//字符串格式化
String.prototype.format = function () {
var values = arguments;
return this.replace(/\{(\d+)\}/g, function (match, index) {
if (values.length > index) {
return values[index];
} else {
return "";
}
});
};
转载于:https://www.cnblogs.com/yangyangming/p/11611303.html