Below is the preparation code for explaining my concerns,
function Person(name) {
this.name = name;
}
Person.prototype.getname = function(){
return this.name;
}
function test(){}
test.prototype = new Person('why')
var p = new test();
console.log(p.getname()) // the outcome is ofcourse 'why'
p.__proto__.name = 'go'
console.log(p.getname()) // the outcome has been changed to 'go'
and here comes the problem.
test.prototype = new Person('goo')
console.log(p.getname()) // the outcome is still 'go' not 'goo'
why the outcome still 'go' not 'goo'?
is there any difference between
p.__proto__.name = 'go' vs test.prototype = new Person('goo')?
guess I`m now misunderstanding the internal operation systems.
need some help,