js继承问题
有关js继承的问题;
function Parent(){
this.name = 'huachenyu'
}
function Child() {
this.age = 12
}
Child.prototype = new Parent(); //Child继承Parent
var test = new Child();
alert(test.age) //12
alert(test.name) //huachenyu
function bro(){
this.sex = 'boy'
}
bro.prototype = new Child(); //同理,bro继承Child
var test1 = new bro();
alert(test1.sex) //boy