Javascript Object Inheritance
function Person(firstName, lastName) { this.firstName = firstName;/*from ww w .ja va 2s .com*/ this.lastName = lastName; } Person.prototype.getFullName = function() { return this.firstName + " " + this.lastName; }; function Employee(firstName, lastName, position) { Person.call(this, firstName, lastName); this.position = position; } Employee.prototype = new Person(); Employee.prototype.getFullName = function() { let fullName = Person.prototype.getFullName.call(this); return fullName + ", " + this.position; }; let employee = new Employee("CSS", "HTML", "Author"); console.log(employee.getFullName());