Javascript 在原型中使用对象参数

Javascript 在原型中使用对象参数,javascript,prototype,Javascript,Prototype,这可能吗 function testObj(testArg) { //Do obj stuff here } testObj.prototype.addFn = function() { this.test = testArg; } 这将不起作用,因为原型无法使用原始对象参数,但是有没有一种方法可以访问它们而不必通过函数再次传递它们 function testObj() { // take a copy of the arguments this._args

这可能吗

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

testObj.prototype.addFn = function() {
    this.test = testArg;
}
这将不起作用,因为原型无法使用原始对象参数,但是有没有一种方法可以访问它们而不必通过函数再次传递它们

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];
}