作业二:创建一个原型继承,画出原型链图
function human(name,age,sex){
this.name=name;
this.age=age;
this.sex=sex;
}
human.prototype.eat=function(){
console.log(this.name+'正在吃饭')
}
human.prototype.sleep=function(){
console.log(this.name+"正在睡觉")
}
function teacher(name,age,sex){
human.call(this,name,age,sex)//冒充
}
teacher.prototype=new human('小明',15,'男');//原型
teacher.prototype.tech=function(){
console.log(this.name+'正在教学');
}
var t1=new teacher('张老师',24,'女');
console.log(t1);
t1.tech();
t1.eat();//思考eat方法是如何查找的