When I checked instanceof method, the results are not same .
function A(){}
function B(){};
First I assigned prototype ( reference ) property , into A
A.prototype = B.prototype;
var carA = new A();
console.log( B.prototype.constructor );
console.log( A.prototype.constructor == B );
console.log( B.prototype.constructor == B );
console.log( carA instanceof A );
console.log( carA instanceof B );
The last 4 condition on above returns true .
But when I tried to assign constructor of B .. results are not same .
A.prototype.constructor = B.prototype.constructor;
var carA = new A();
console.log( B.prototype.constructor );
console.log( A.prototype.constructor == B );
console.log( B.prototype.constructor == B );
console.log( carA instanceof A );
console.log( carA instanceof B );
On this case carA instanceof B returns false . Why it returns false