I have this problem ... B is the base class, and A is the derived class ... An event, although A is derived from B, different objects of A point to the same object B.
I know that I assigned object B to prototype A to make A child of B.
But different objects A, they must have different address space for storing variables, right? Can you fix this?
function B(){ this.obj = {}; } function A(){ } A.prototype = new B(); var a = new A(); var b = new A(); var c = new A(); console.log(a.obj == b.obj);
What change should I make to this code to give me the following result.
a.obj === b.obj //must be false a instanceof A; //must be true a instanceof B; //must be true
source share