Functions

The this keyword

How this is determined by how a function is called.

intermediate All levels

this is not fixed at definition time — it is set by how a function is called (its call site).

`this` is like the word "here" — its meaning depends entirely on where it is spoken, not where it was written down.

Key concepts

1
The four binding rules, in priority order: new binding (a constructor call), explicit binding (call/apply/bind), implicit binding (called as obj.method(), so this is obj), and default binding (undefined in strict mode, otherwise the global object).
newexplicitimplicitdefaultcall
2
Arrow functions ignore all of that — they capture this lexically from the enclosing scope, which is exactly why they are handy for callbacks inside methods.
Arrow functionsthis