I know you can have one javascript instantiated object inherit the prototype of another constructor with constructer.prototype.__proto__ = otherConstructer.prototype, but can you use the call method like this to do the same thing?:
function constructor () {
otherConstructor.call(this);
}
No, the prototype can’t be replaced except by referencing the object itself and directly replacing it with the __proto__ property, which doesn’t exist in all implementations. Look at this sample code:
As you can see, the B constructor is correctly called and the object setup is from B and not A, but nevertheless the object’s prototype is still from A. You can, of course, replace individual functions:
If you want a great explanation of why this is so, check out the accepted answer to this question.
Edit: There is no association with B.prototype when an A object is created. If you changed the code so that A.prototype.testfunc is not defined, then even though the A constructor calls B, nevertheless calling test.testfunc() will result in an undefined exception.