在此列中,将构造函数的constructor指向一个字符串后,其构造函数为字符串,那么developer.constructor.prototype就应该为undefined,但实例为什么仍能访问其构造函数原型链上的属性
var monkey = {
feeds:'bananas',
breathes:'air'
}
function Human(){}
Human.prototype = monkey;
var developer = new Human();
developer.constructor = 'junk'
developer.breathes ; //"air"
monkey.test =1;
developer.test;
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
developer.constructor !== developer.__proto__.constructor简而言之,原型链是只读的,你只能访问而不能修改
你单步调试,把所有的变量都展开看看,就什么都明白了。