Skip to content

Instantly share code, notes, and snippets.

@haalogen
Created March 1, 2019 12:02
Show Gist options
  • Save haalogen/a02b021c4ad599883987c5b79e95a092 to your computer and use it in GitHub Desktop.
Save haalogen/a02b021c4ad599883987c5b79e95a092 to your computer and use it in GitHub Desktop.
// ES5 Function Constructor
function Student(name, studentId) {
// Call constructor of superclass to initialize superclass-derived members.
Person.call(this, name);
// Initialize subclass's own members.
this.studentId = studentId;
}
Student.prototype = Object.create(Person.prototype);
Student.prototype.constructor = Student;
// ES6 Class
class Student extends Person {
constructor(name, studentId) {
super(name);
this.studentId = studentId;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment