js 备忘

function showArg3() {
    alert(this.arguments[3]);
}


function createObj(arg1, arg2) {
    var obj = new Object();
    obj.arg1 = arg1;
    obj.arg2 = arg2;
    obj.showArg3 = showArg3;


    return obj;
}

 

----------------------------------------------------------------------------

 

function StringBuffer() {
    this._strings_ = new Array();
    if (typeof StringBuffer._initialized == "undefined") {
        StringBuffer.prototype.append = function(str) {
            this._strings_.push(str);
        };
        StringBuffer.prototype.toString = function() {
            return this._strings_.join("");
        };
        StringBuffer._initialized = true;
    }
}

 

------------------------------------------------------------------------------

 

function ClassA(arg1) {
    this.agr1 = arg1;
    this.showAgr1 = function() {
        alert(this.arg1);
    };
}

 

function ClassB(arg1, arg2) {
    //this.newMethod = ClassA;
    //this.newMethod(arg1);
    //delete this.newMethod;
    //ClassA.call(this, arg1);
    ClassA.apply(this, new Array(arg1));


    this.agr2 = arg2;
    this.showAgr2 = function() {
        alert(this.arg2);
    };
}

 

------------------------------------------------------------------------------

 

function ClassAA(arg1) {
    this.agr1 = arg1;
}
ClassAA.prototype.showAgr1 = function() {
    alert(this.arg1);
};

 

function ClassBB(arg1, arg2) {
    ClassAA.call(this, arg1);
    this.agr2 = arg2;
}

//ClassBB.prototype = new ClassAA
ClassBB.prototype.showAgr2 = function() {
    alert(this.arg2);
};

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值