function clone(parent,child) {
child.prototype = Object.create(parent.prototype)
child.prototype.constructor = child
}
function parent(){
this.name = 'name'
}
parent.prototype.getName = function(){
return this.name
}
function Child(){
parent.call(this)
this.name2 = 'name2'
}
clone(parent,Child)
Child.prototype.getName2 = function(){
return this.name2
}
测试
let child = new Child()
console.log(child);
console.log(child.getName());
console.log(child.getName2());
测试结果