0

Is this possible?

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

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

This will not work because the original objects arguments are not available to prototype, but is there a way to access them without having to pass them in all over again through the function?

1 Answer 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];
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.