1.复习下继承
function A(name,age){
this.name=name;
this.age=age;
}
undefined
function B(name,age){
A.call(this,name,age);
}
undefined
B.prototype.sayName=function(){console.log(this.name)}
ƒ (){console.log(this.name)}
B.prototype.sayAge=function(){console.log(this.age)}
ƒ (){console.log(this.age)}
var b1=new B('Sukla',18)
undefined
b1.sayName()
VM264:1 Sukla
undefined
b1.sayAge()
VM361:1 18
undefined
本文深入探讨了JavaScript中函数构造器的继承方式,通过具体示例展示了如何使用call方法实现继承,并对原型链上的sayName和sayAge方法进行了详细解释。
1526

被折叠的 条评论
为什么被折叠?



