Can any one explain why arrow function is displaying "Ram" instead of 'Syam'
?
What I know that this
in arrow function points parent object and normal function points global object but result is different here
this.name="Ram"
var name="Ajay"
var obj ={
name:"Shyam",
show : () => console.log(this.name),
show2: function (){console.log(this.name)}
}
obj.show() // Ram
obj.show2() // Shyam