1// this is how we call method from a super class(i.e MAIN CLASS) to extended class
2class Person {
3 constructor(name, age) {
4 this.name = name;
5 this.age = age;
6 }
7greet() {
8 console.log(`Hi, all my name is ${this.name}`);
9 }
10}
11
12class Employee extends Person {
13 constructor(name, age, employer) {
14 super(name, age); // NOTE : super must call before accessing (this)
15 this.employer = employer;
16 }
17
18 greeting() {
19 super.greet(); // this is how we call
20 console.log(`I'm working at ${this.employer}`);
21 }
22}
23
24let Steve = new Employee('Xman', 25 , 'Skynet');
25Steve;
26Steve.greeting(); // check by consoling MATE