function People(){
}
People.prototype.getName = function(){
console.log('people')
}
function Woman(){
}
Woman.prototype= new People();
Woman.prototype.constructor = Woman ;
let womanObj = new Woman();
2.原型式继承
function People(){
}
People.prototype.getName = function(){
console.log('people')
}
function Woman(){
}
Woman.prototype = People.prototype
let womanObj = new Woman();
2.借用构造函数继承
function People(){
}
People.prototype.getName = function(){
console.log('people')
}
function Woman(){
People.call(this);
}
3.组合式继承
function People(){
}
People.prototype.getName = function(){
console.log('people')
}
function Woman(){
People.call(this);
}
Woman.prototype = People.prototype
let person = new Woman()
1.原型链继承
2.原型式继承
2.借用构造函数继承
3.组合式继承