Problem:
when i am calling a programmer child class's method (overridden method) by using programmer class's object its calling parent Employee class's method.
What i've tried:
parent class's method is a arrow function but child classs's method is a normal function.If i make parent class's method as normal method it solves the problem but my question is why did this happen?
Can someone please explain this behaviour ?
here's the code:
class Employee {
constructor(name){
this.name = name;
}
login = ()=>{
console.log("Employee "+this.name+" logged in...");
}
}
class Programmer extends Employee{
login(){
console.log("Programmer "+this.name+" logged in...");
}
}
let emp = new Programmer("Ankur");
emp.login();