I am learning how inheritance work in JavaScript and came across following situation.
If we change Ninja prototype completely with new Object then we lost the connection with old prototype. Look at the below picture.
Here we loose the connection with old prototype and it's old constructor function. Then how ninja instanceof Ninja assert to true? we don't have any direct connection with Ninja prototype.
Please tell me how instanceof operator find Ninja prototype on ninja object prototype chain?


Ninja.prototypeon the prototype chain - nothing cares about the old prototype object which is not referenced by anything.