Q8: How does the `this` keyword work in different execution contexts?

The value of this depends on how a function is called: standard method call (obj.fn()) sets this to obj; plain function call sets this to window/undefined (strict mode); constructors (new Fn()) bind this to the new instance; arrow functions bind this lexically from their outer scope.

Key Takeaways
  • Standard function this is bound dynamically at call time.
  • Arrow function this is determined statically from lexical outer scope.
Knowledge Check

What is `this` inside an arrow function defined within an object method?