高效的Javascript 字符串操作类

/**************************************************
* * 字符串操作类
* * 2008-7-25
* **************************************************
* * msn:danxinju@hotmail.com
* * author:淡新举
***************************************************/
var StringBuilder = function(){
this.arr = new Array();
};

//追加字符串
StringBuilder.prototype.add = function(item){
this.arr.push(item);
};

//清空字符
StringBuilder.prototype.clear = function(){
this.arr.length = 0;
};

//转换为String
StringBuilder.prototype.toString = function(){
return this.arr.join("");
};
posted on 2009-05-07 09:56  念时  阅读(321)  评论(0编辑  收藏  举报

细节决定成败!态度决定一切!