借助构造函数实现继承(解决引用类型问题)

来源:互联网 发布:数据挖掘公司排名 编辑:程序博客网 时间:2024/06/05 18:15
function Person(){this.name='li';this.sex='boy';}function Boy(){Person.call(this)}var child=new Boy();alert(child.name);//lialert(child.sex);//boy//缺点:无法继承超类型原型上的;