JS Built-ins
Functionbindbeginner

Function.prototype.bind() β€” bound this.x

πŸ“– Usage Example
const doubled = [1,2,3].map(n => n * 2)
// Arrow functions don't need bind() β€” they capture this lexically

Arrow functions lexically capture this and never need bind().

bind() β€” accessing this.x

When a function references this.x, binding it to an object with x: 42 ensures it always returns 42.

Challenge: Bind fn to {x: 42} and verify bound() returns 42.

πŸ’‘ Hints (1)
  • β€’ `this.x` resolves to the bound context's `x` property.