<div class="codetitle"> <span><a style="CURSOR: pointer" data="61884" class="copybut" id="copybut61884" onclick="doCopy('code61884')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code61884"> <br>function StringBuffer(){ <br>this.__strings__ = new Array(); <br>} <br>StringBuffer.prototype.append = function(str){ <br>this.__strings__.push(str); <br>}; <br>StringBuffer.prototype.toString = function(){ <br>this.__strings__.join(" "); <br>}; <br> </div> <br>其实上面的代码,主要利用了js的数组原理实现。