I created an object with object constructor ,made a prototype function.But when I called that function 'this' keyword not referring to object
function Person(name,age,location){
this.name = name;
this.age = age;
this.location = location;
}
var person1 = new Person('john',22,'Pakistan');
Person.prototype.greet = ()=>{
console.log(this.name + "says Hi");
};
person1.greet();
But when I used simple anonymous function ,the problem gets solved.
Person.prototype.greet = function(){
console.log(this.name + "says Hi");
};
Why it's not working with arrow function?