Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion JS基础/原型链与继承.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Child.prototype = Parent.prototype;
- 因为原型上有一个属性为`constructor`,此时直接使用父类的 prototype 的话那么会导致 实例的 constructor 为 Parent,即不能区分这个实例对象是 Child 的实例还是父类的实例对象。
- 子类不可直接在 prototype 上添加属性和方法,因为会影响父类的原型

注意:这个时候 instanseof 是可以判断出实例为 Child 的实例的,因为 instanceof 的原理是沿着对象的**proto**判断是否有一个原型是等于该构造函数的原型的。这里把 Child 的原型直接设置为了父类的原型,那么: 实例.**proto** === Child.prototype === Child.prototype
注意:这个时候 instanseof 是可以判断出实例为 Child 的实例的,因为 instanceof 的原理是沿着对象的**proto**判断是否有一个原型是等于该构造函数的原型的。这里把 Child 的原型直接设置为了父类的原型,那么: 实例.**proto** === Child.prototype === Parent.prototype

### 组合继承方式 优化 2 - 添加中间对象【最通用版本】:

Expand Down