一、基于prototype原型
function Person(name){ this.name = name; } Person.prototype.eat="food"; function Student(name,eat){ Person.apply(this, arguments); } Student.prototype = new Person(); var s1 = new Student("王大", "food"); console.log(s1.name); console.log(s1.eat);