I am learning JS and I am told that if I want to extend a class I need to use a constructor and super(). But when I was experimenting I discovered that I can extend the class without. I tried to find an explanation on the internet but couldn't find one. Can somebody explain to me? Thanks
class Person {
constructor(name, email, address) {
this.name = name;
this.email = email;
this.adress = address;
}
}
class Employee extends Person {
getName() {
return (
"Hi!," +
this.name +
" who has " +
this.email +
" as email and lives in " +
this.adress
);
}
}
const newEmployee = new Employee("Ahmed", "ahmed@test.com", "Beverly Hills");
console.log(newEmployee.getName()); *// Hi!,Ahmed who has ahmed@test.com as email and lives in Beverly Hills*