- call
- apply
- bind
- method calls
- arrow lexical this
A normal function receives this from its call site. Calling object.method() supplies the object, while extracting the method usually loses that receiver. call and apply invoke with an explicit receiver; bind creates a new function with a fixed receiver. Arrow functions capture this from their surroundings and cannot be rebound.
Assuming this belongs to where a function was written causes detached handlers and callbacks to fail.
Create an object method, detach it, then compare call, bind, and an arrow callback.
Open example.html, inspect example.js, then edit and refresh. For APIs that need an origin, run a local server from the JavaScripts folder.
- Explain the behavior and its limits in your own words.
- Test a normal case and a failure or cleanup case.
- Record when this feature is useful and when a simpler approach is better.