In below code
var A = function() {};
var a = new A();
var b = new A();
A.prototype = {};
var c = new A();
console.log(a.constructor === b.constructor);
con
When using function as an object constructor, its prototype.constructor
is automatically created with function's property. So initially after setting up the A function you will have a constructor in A's prototype:
A.prototype.constructor
So when you assign A.prototype ={}, you lost that original constructor in A.prototype
.
You may fix it with adding this after A.prototype ={}
line
A.prototype.constructor = A;
Both console should log true