class Component {}
class Greeting extends Component {}
上面的例子,Greeting继承Component意味着
一. Greeting.__proto__ === Component
二. Greeting.prototype.__proto__ === Component.prototype
也就是说 new Greeting().__proto__.proto__ === Component.prototype
new Greeting().__proto__.__proto__ === new Component().__proto__
本文详细探讨了JavaScript中类的继承机制,通过具体实例解释了如何通过类继承实现原型链的连接,以及new操作符创建对象时原型链的传递过程。
1570

被折叠的 条评论
为什么被折叠?



