Prototype inheritance
function A(){
this.name = '小明'
}
function B(name){
this.eat = function(){
console.log('调用b中的eat')
}
}
// 实现a函数继承b函数
A.prototype = new B()
new A().eat()
call and apply implement inheritance
function A(){
B.call(this)
this.name = '小明'
}
function B(){
this.eat = function(){
console.log('调用b中的eat')
}
}
new A().eat()