实现代码如下:

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

其实上面的代码,主要利用了js的数组原理实现。

以上就是【javascript下高性能字符串连接StringBuffer类】的全部内容了,欢迎留言评论进行交流!

赞(0) 踩(0)
发表我的评论

最新评论

  1. 暂无评论