Docs

Namaste JavaScript — Interview Quick Notes

Ep 25: this Keyword


  • Global scope → this is window (browser).
  • Regular function (non-strict) → window (this substitution).
  • Regular function (strict) → undefined.
  • Object method → the object the method is called on.
  • Arrow function → inherited from enclosing lexical scope (no own this).
  • DOM event handler → the HTML element that fired the event.
  • call(ctx, ...args), apply(ctx, [args]), bind(ctx) — all explicitly set the value of this.
  • Arrow functions cannot have their this overridden with call/apply/bind.