'This' is not the same in constructor and inherited constructor

Viewed 70

I have this simple inheritance pattern:

function Emitter() {
    this.dis1 = this;
};

function Person() {
    this.dis2 = this;
};
Person.prototype = new Emitter();
var p1 = new Person();
var p2 = new Person();

console.log(p1.dis1 === p2.dis1); //true - why?
console.log(p1.dis2 === p2.dis2); //false

Why are dis1 of separate objects the same? Is there a workaround for this?

3 Answers
Related