Example 1 — Losing this
Extracting a method can lose the object.
JavaScript
const user = { name: "Ada", hello(){ return this.name; } };
const fn = user.hello;
console.log(typeof fn());How It Works
- fn() is a plain call.
- this is not user (undefined in strict mode).
