Fork me on GitHub

js实现 StringBuilder

function StringBuilder()
{
 this._stringArray = new Array();
}

StringBuilder.prototype.append = function(str)
{
 this._stringArray.push(str);
}

StringBuilder.prototype.toString = function(joinGap)
{
 return this._stringArray.join(joinGap);
}

function TestArray()
{
    var stringBuilder = new StringBuilder();
    stringBuilder.append("good");
    stringBuilder.append("moring");
    var str= stringBuilder.toString(" ");
    alert(str);
}

 详细:

https://www.cnblogs.com/matthew/archive/2008/08/15/1268843.html

posted @ 2021-03-05 14:45  HelloLLLLL  阅读(26)  评论(0编辑  收藏  举报