JS高性能字符串连接StringBuffer类[转]

来源:互联网 发布:淘宝导航条怎么换颜色 编辑:程序博客网 时间:2024/05/21 10:47

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

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

原创粉丝点击