function Child({name, age}) {
this.name = name
this.age = age
this.eat = function (){
console.log(`${name} 正在吃饭`)
}
}
function Parent() {
Parent.prototype.aa = 'aaa'
}
Parent.prototype = new Child({
name: '哈哈哈',
age: 18
})
var parent = new Parent()
var child = new Child({name: '111', age: 100})
console.log(parent.eat())
console.log( child.eat())
console.log(this)
function Child({name, age}) {
this.name = name
this.age = age
this.eat = function (){
console.log(`${name} 正在吃饭`)
}
}
function Parent() {
Child.call(this, {
name: '金凤', age: 100
})
this.kkk = 'kkk'
}
var parent = new Parent()
var child = new Child({name: '111', age: 100})
console.log(parent.eat())
console.log(child)