在javascript中寄生组合继承和组合继承有什么区别? [英] What is the difference between Parasitic Combination Inheritance and Combination Inheritance in javascript?

查看:129
本文介绍了在javascript中寄生组合继承和组合继承有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这两种类型的继承的示例代码在这里:

The example codes of these two types of inheritance are here:

寄生组合继承: http://jsfiddle.net/dKKaS/

组合继承: http://jsfiddle.net/XZn3A/

有人可以告诉我区别吗?谢谢。

Could someone tell me the difference? Thanks.

推荐答案

答案是,通过寄生组合继承,基础构造函数只调用一次。使用组合继承,构造函数被调用两次。

The answer is that with Parasitic Combination Inheritance, the base constructor is only called once. With Combination Inheritance, the constructor gets called two times.

这篇关于在javascript中寄生组合继承和组合继承有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆