Answer the question
In order to leave comments, you need to log in
Why do sometimes changes to the "parent" prototype affect changes to the "child" prototype, and sometimes not?
Why sometimes changes in the "parent" property prototype
of the constructor function affect the change in prototype
the instance object contained in __proto__
, and sometimes not?
That is, here changes in the "parent" instance prototype
do not affect the "child" prototype
instance in any way:
function Rabbit() {}
Rabbit.prototype = {
eats: true
};
var rabbit = new Rabbit();
Rabbit.prototype = {};
alert( rabbit.eats ); //true - все работает без изменений
function Rabbit(name) {}
Rabbit.prototype = {
eats: true
};
var rabbit = new Rabbit();
Rabbit.prototype.eats = false;
alert( rabbit.eats ); //false - происходят изменения
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question