笔记:JS高性能字符串连接StringBuffer类

 

function StringBuffer(){
  this.__strings__ = new Array(); 
} 
StringBuffer.prototype.append = function(str){
  this.__strings__.push(str); 
}; 
StringBuffer.prototype.toString = function(){ 
  this.__strings__.join(" "); 
};

使用StringBuffer类比使用加号节省50%左右的时间...

posted @ 2010-08-15 00:00  rock506  阅读(417)  评论(2编辑  收藏  举报