原型链练习

作业 画出原型链

//动物--->人---->老师---->坏老师

function Animal(){
this.gender = "male";
}

var animal=new Animal();//实例化
Human.prototype = new Animal();
Human.prototype.constructor = Human;

function Human(){
this.actionWay = "走路";
}

Teacher.prototype = new Human();
Teacher.prototype.constructor = Teacher;
function Teacher(){
this.skill = "教书";
}

BadTeacher.prototype = new Teacher();
BadTeacher.prototype.constructor = BadTeacher;
function BadTeacher(){
this.name = "俞敏洪";
}

var t = new BadTeacher();
console.log(t);
console.log(t.name);
console.log(t.skill);
console.log(t.actionWay);

posted @ 2018-05-29 16:38  V仔BOKE  阅读(206)  评论(0编辑  收藏  举报