Javascript StringBuffer 类

 

function StringBuffer(){
this.data = [];
}

StringBuffer.prototype.append 
= function(){
this.data.push(arguments[0]);
return this;
}

StringBuffer.prototype.toString 
= function(){
return this.data.join("");
}


// 应用 
var a = new StringBuffer();
for (i=0; i<1000; i++){
 a.append(
"<li>Item</li>");
}
 
document.write(a.toString())

posted @ 2007-07-18 01:17  Samgle  阅读(696)  评论(1)    收藏  举报