ES5
function Person(name, age) { this.name = name; this.age = age;}function Student(name, age, grade) { Person.call(this, name, age); this.grade = grade;}
Student.prototype = Object.create(Person.prototype);// Object.create() 메서드는 지정된 프로토타입 객체 및 속성(property)을 갖는 새 객체를 만듭니다.// Object.create(proto[, propertiesObject])Student.prototype.constructor = Student;// 확인!const student = new Student('boseok', 10, 'SSS');student instanceof Student; // truestudent instanceof Person; // trueES6
// ESclass Student extends Person { constructor(name, age, grade) { super(name, age); this.grade = grade; }}// ES6class Person { constructor(name, age) { this.name = name; this.age = age; }}