function Person(){}
Person.prototype.eat = function() {
console.log(“吃饭”);
};
Person.prototype.sleep = function() {
console.log(“睡觉”);
};
Person.prototype.play = function() {
console.log(“打游戏”);
};
function Student() {}
// 原型链继承(一句话继承)
Student.prototype = new Person();
var stu = new Student();
stu.eat();
stu.sleep();
stu.play();
function Teacher() {}
// 原型链继承
Teacher.prototype = Object.create(Person.prototype);