javascript下高性能字符串连接StringBuffer类


复制代码 代码如下:

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

其实上面的代码,主要利用了js的数组原理实现。
« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3