this in the arrow function of call back function and this in the anonymous function of the call back function , why both differs?

Viewed 9
function Person() { setTimeout( function() { console.log(this) },1000) } 

const me = new Person()

output for this is

Window {0: global, window: Window, self: Window, document: document, name: '', location: Location, …}

function Person() { setTimeout( () =>  { console.log(this) },1000) } 
const you = new Person()

out put for this is

Person {}

can I know why this differs in arrow and anonymous function ??

0 Answers
Related