0

これは可能ですか?

function testObj(testArg) {
    //Do obj stuff here
}

testObj.prototype.addFn = function() {
    this.test = testArg;
}

元のオブジェクトの引数はプロトタイプに使用できないため、これは機能しませんが、関数を介してもう一度渡すことなくそれらにアクセスする方法はありますか?

4

1 に答える 1

1
function testObj() {
    // take a copy of the arguments
    this._args = [].slice.call(arguments, 0);

    // Do obj stuff here
}

testObj.prototype.addFn = function() {
    this.test = this._args[0];
}
于 2012-06-16T16:21:31.243 に答える