Object instances do not have a member called prototype
unless they are functions (var f = new Function() is a Function instance). It is explained in the link I posted in the comment and this answer.
Instanceof can depend on when you replace the prototype and the __proto__
for instances created by the same constructor function can be different.
var pr = {
speak:function(){
console.log('I am the original');
}
};
var Animal = function(){};
Animal.prototype = pr;
var original = new Animal();
//Now we de reference the prototype of Animal
// this will cause instances already created to
// still use original but new instances will use the copy
Animal.prototype = {
speak:function(){
console.log('I am changed');
}
};
var changed = new Animal();
console.log(original.speak());//=I am the original
console.log(changed.speak());//=I am changed
A much simpler example (without using prototype) shows what is going on here:
var org = {name:'org'};
var copy = org;//org and copy point to the same object
console.log(copy === org);//true
copy.name='first change';//mutating copy will affect org
//because they point to the same object
console.log(org.name);//=first change
copy = {name:'de reference'};//re assigning copy will de reference copy
//copy no longer points to the same object as org
console.log(copy === org);//=false
console.log(org.name);//=first change
So when prototype is involved something similar happens.
The Animal instance stored in original
uses pr as it's prototype but the Animal instance changed
does not, the reason why original still uses pr is because we de referenced the prototype. When you mutate the prototype something different happens. Based on the simpler example above you may guess what that is.
It is not advisable to re assign the prototype after creating instances as this could negatively affect optimization and confuse anyone trying to maintain your code.
More info on prototype and inheritance patterns can be found here:
https://stackoverflow.com/a/16063711/1641941