javascript StringBuilder类使用方法源码实例介绍

javascript StringBuilder类使用方法源码实例介绍,以下是截取的部分js代码:

{
this.cache = [];
if(arguments.length)this.append.apply(this,arguments);
}StringBuilder.prototype = { // StringBuilder类使用方法
prepend:function(){
this.cache.splice.apply(this.cache,[].concat.apply([0,0],arguments));
return this },
append:function(){
this.cache = this.cache.concat.apply(this.cache,arguments);
return this },
toString:function(){
return this.getString();
},
getString:function(){
return this.cache.join(‘);
}} 本文链接地址: javascript StringBuilder类使用方法源码实例介绍