js 字符连接对象

function StringBuffer(){
     this.str = [];
}

StringBuffer.prototype = {
    append:function(str){
        this.str.push(str);
        return this;
   },
   toString:function(){
        return  this.str.join('');
   },
   clear:function(){
       this.str.length = 0;
       return this;
  }
}

猜你喜欢

转载自it-dodo.iteye.com/blog/2324582
今日推荐