Class Inheritance Hierarchy in OOP in JavaScript
It is possible to inherit from a class that is itself a descendant. Let's look at an example. Let's say we have the following parent class:
class User {
setName(name) {
this._name = name;
}
getName() {
return this._name;
}
}
The following class inherits from this class:
class Student extends User {
setYear(year) {
this._year = year;
}
getYear() {
return this._year;
}
}
And another class inherits from this class:
class StudentProgrammer extends Student {
setSkill(skill) {
this._skill = skill;
}
getSkill() {
return this._skill;
}
}
Make a class Employee that will inherit from the class User.
Make a class Programmer that will inherit from the class Employee.
Make classes Designer that will inherit from class Employee.
Add various methods to the classes you created.