工作中,经常用到一些公共的函数来简化工作.我们自己可以封装一些函数.我的思想是先把JQUERY这样的经典库直接搬来,然后再接着封装.搭建一个属于我们的库。我先发几个。我的联系方式MSN:[email protected]

解决方案 »

  1.   

    function StringBuffer() {
    this.__strings__ = new Array;
    }StringBuffer.prototype.append = function(str) {
    this.__strings__.push(str);
    return this;
    };StringBuffer.prototype.toString = function() {
    return this.__strings__.join("");
    };
    用法:
    var buffer=new StringBuffer()
    buffer.append.('a').append('b');
    buffer.toString();