JS字符串格式化

//字符串格式化
String.prototype.format = function () {
var values = arguments;
return this.replace(/\{(\d+)\}/g, function (match, index) {
if (values.length > index) {
return values[index];
} else {
return "";
}
});
}; 
posted @ 2019-09-30 10:19  一只小羊  阅读(9240)  评论(0编辑  收藏  举报