I have the following code:
var A = function() {};
var a = new A();
var b = new A();
A.prototype.member1 = 10;
A.prototype = {}
var c = new A();
console.log(a.member1);
console.log(a.constructor === b.constructor);
console.log(a.constructor === c.constructor);
console.log('---------');
console.log(c.member1);
At the exit:
10
true
false
---------
undefined
undefined
Prototype aand bhas not changed, and c- a new one. Was this right due to what is a.constructornot equal c.constructor, and each of them has prototype? Are there any other loops where the constructors of two objects may not be equal?
Additional question: why were two lines printed undefined? (Chromium)
source
share