JS Built-ins
Functionbindbeginner

Function.prototype.bind() β€” returns a function

πŸ“– Usage Example
const obj = { x: 10 }
function getX() { return this.x }
const fn = getX.bind(obj)
fn()  // β†’ 10

Use bind() when passing a method as a callback to preserve its this context.

bind() returns a function

bind() always returns a new function regardless of the original function. typeof the result is 'function'.

Challenge: Verify that typeof greet.bind({}) returns 'function'.

πŸ’‘ Hints (1)
  • β€’ `bind()` always returns a new function object.