共计 228 个字符,预计需要花费 1 分钟才能阅读完成。
1. 原型链继承
function Parent(){this.name='jean'} | |
Child.prototype===new Parent(); |
2. 借用构造函数继承
用.call()和.apply()将父类构造函数引入子类函数。
function Child(){Parent.call(this,'') | |
} |
3. 组合继承
function Child(name){Parent.call(this,name); | |
} | |
Child.prototype===new Parent() |
正文完
发表至: javascript
2019-08-21