function Person(){
this.name='li';
this.sex='boy';
}
function Boy(){
Person.call(this)
}
var child=new Boy();
alert(child.name);//li
alert(child.sex);//boy
//缺点:无法继承超类型原型上的;
借助构造函数实现继承(解决引用类型问题)
最新推荐文章于 2021-01-22 15:08:58 发布
function Person(){
this.name='li';
this.sex='boy';
}
function Boy(){
Person.call(this)
}
var child=new Boy();
alert(child.name);//li
alert(child.sex);//boy
//缺点:无法继承超类型原型上的;