Created
March 1, 2019 12:02
-
-
Save haalogen/a02b021c4ad599883987c5b79e95a092 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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