构造函数的继承
function parent() {
this.name = 1
this.play = [3,4]
}
parent.prototype.say = function () {
console.log('say')
}
function children() {
parent.call(this)
this.age = 2
}
console.log(new children().name)
console.log(new children().say())
结果如图:这样的继承只可以继承父函数的自身属性,不可以继承原型链say属性,也就是说只可以部分继承
原型链继承
function parent2() {
this.name = 1
this.play = [3,4]
}
parent2.prototype.say = function () {
console.log('say')
}
function children2() {
this.age = 2
}
children2.prototype = new parent2();
console.log(new chil