We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
分类见最下面
原型链继承
SubType.prototype = new SuperType()
构造函数继承
function SubType(){ //继承自SuperType SuperType.call(this); }
组合继承 (原型 + 构造)
SubType
prototype
instance
组合寄生继承
Object.creat
SuperType
此时,SubType的prototype没有重复的属性
保证一个纯净(不含父元素实例的属性和方法)的subtype的prototype
The text was updated successfully, but these errors were encountered:
nice blog
Sorry, something went wrong.
thank you!
No branches or pull requests
JavaScript继承分类及其作用-总结
先上分类
分类见最下面
自己的理解(用的最多的几个)
原型链继承
SubType.prototype = new SuperType()
构造函数继承
组合继承 (原型 + 构造)
SubType
的prototype
里面有重复的属性,会被SubType
的instance
的属性覆盖掉组合寄生继承
prototype
:Object.creat
一个新的对象,此对象只继承SuperType
的prototype
SubType
得以使用父代的prototype:将SubType
的prototype
指向新的对象。此时,SubType的prototype没有重复的属性
SubType
得到父代instance
的属性:SubType
内部使用构造函数继承,内部使用SubType.prototype = new SuperType()
,得到父代实例的属性保证一个纯净(不含父元素实例的属性和方法)的subtype的prototype
下面是自己画的图 组合寄生继承
分类
BYvoid 大神的图
The text was updated successfully, but these errors were encountered: