Created
June 7, 2018 18:35
-
-
Save neerajkumar/d568dcf47e8af56099c5b3703275ae77 to your computer and use it in GitHub Desktop.
ES5 Inheritence - Javascript Solution
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
function Person(first_name, last_name) { | |
this.first_name = first_name; | |
this.last_name = last_name; | |
} | |
Person.prototype.getFullName = function() { | |
return this.first_name + ' ' + this.last_name; | |
} | |
function Student(studentId, first_name, last_name) { | |
this._super.call(this, first_name, last_name); | |
this.studentId = studentId; | |
} | |
Student.prototype._super = Person; | |
Student.prototype.getStudentInfo = function() { | |
return this.studentId + ', ' + this.first_name + ' ' + this.last_name; | |
} | |
var student = new Student(1, 'Neeraj', 'Kumar'); | |
console.log(student.getStudentInfo()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment