How instanceof is implemented in JavaScript -
How instanceof is implemented in JavaScript -
this question has reply here:
how instanceof work in javascript? 2 answerslets consider next code snippet:
function a() {} var obj = new a(); function b() {}; obj.constructor = b; console.info("1: ", obj.constructor); //function b console.info("2: ", obj instanceof a); //true console.info("3: ", obj instanceof b); //false
my guess decide if , object instance of function class or not, js engine must checking if object has same constructor property or not. not seem happening so, overriding constructor property of object not alter it's instanceof output.
this link states:
the instanceof operator tests presence of constructor.prototype in object's prototype chain.
javascript
Comments
Post a Comment