87,917
社区成员
发帖
与我相关
我的任务
分享
String.prototype.format=function()
{
var args = Array.prototype.slice.call(arguments, 0);
return this.replace(/\{(\d+)\}/g,function(m,i){ return args[i];});
}
var cls = 'my-class', text = 'Some text';
var s = '<div class="{0}">{1}</div>'.format(cls, text);
alert(s);