0

When I execute myCallback through setTimeout. How is this evaluated inside myCallback ?

setTimeout(myCallback, 1000); 
// is 'this' inside myCallback going to be the same as
// if I invoked myCallback directly like this: myCallback() ?
Lev
  • 10,276
  • 14
  • 44
  • 77

1 Answers1

0

myCallback function will be invoked in a new scope, so "this" from the current object wont be available anymore and instead, "this" will refer to the global "window" object

Ben Yitzhaki
  • 1,316
  • 17
  • 30