Arrow receiver vs a bound normal function
Trace which call controls this in each case.
Code Snippet
function makeReaders() {
const arrow = () => this.city;
const normal = function () { return this.city; };
return [arrow, normal.bind({ city: "Pune" })];
}
const [a, b] = makeReaders.call({ city: "Nagpur" });
console.log(a.call({ city: "Delhi" }));
console.log(b.call({ city: "Delhi" }));Expected Output & Explanation
Nagpur
Pune The arrow uses the this of makeReaders. The normal function’s bound receiver wins over a later explicit receiver supplied to the bound wrapper.
Module Context & References
JavaScript · Language output drills Trace closures, receivers, prototypes, coercion and array edge cases
Personal Notes · Markdown