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
  • 13,856
  • 14
  • 52
  • 84

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,376
  • 16
  • 31