inheritanceTest
by Paco86
JavaScript
function Person(name){
this.name = name;
}
Person.prototype.eat = function(){
console.log('eat');
}
function Student(name){
Person.call(this, name);
}
Student.prototype = Object.create(Person.prototype);
Student.constructor = Student;
let p = new Person('jj');
let s = new Student('jj');
s.eat()