console.time('111');
var str = "";
for (var i=0; i < 10000; i++) {
str += "text";
}
console.timeEnd('111');
console.time('2222');
function StringBuffer () {
this._strings_ = new Array();
}
StringBuffer.prototype.append = function(str) {
this._strings_.push(str);
};
StringBuffer.prototype.toString = function() {
return this._strings_.join("");
};
var buffer = new StringBuffer();
for (var i=0; i < 10000; i++) {
buffer.append("text");
}
var result = buffer.toString();
console.timeEnd('2222');