We can also declare a new class that inherits from a class, which is already inheriting from another class. In the following code snippet, we declare a class called SchoolPrincipal that extends the Teacher class, which extends the Person class:
class SchoolPrincipal extends Teacher { public manageTeachers() { return console.log( `We need to help our students!` ); } }
If we create an instance of the SchoolPrincipal class, we will be able to access all the properties and methods from its parent classes (SchoolPrincipal, Teacher, and Person):
const principal = new SchoolPrincipal( "Remo", "Jansen", "remo.jansen@wolksoftware.com" ); principal.greet(); // "Hi!" principal.teach(); // "Welcome to class!" principal.manageTeachers(); ...