How instanceof is implemented in JavaScript -



How instanceof is implemented in JavaScript -

this question has reply here:

how instanceof work in javascript? 2 answers

lets 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

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -