Function.prototype.bind Polyfill

Implement Function.prototype.myBind — a polyfill for the native Function.prototype.bind.

bind(thisArg, ...boundArgs) returns a new function where:

  • this is permanently set to thisArg
  • Any arguments passed to bind beyond thisArg are pre-filled (partial application)
  • Arguments passed when calling the bound function are appended after the pre-filled ones
function greet(greeting, name) {
  return `${greeting}, ${name}! I'm ${this.title}`;
}

const obj = { title: "Dr" };
const boundGreet = greet.myBind(obj, "Hello");
boundGreet("Alice"); // "Hello, Alice! I'm Dr"
Examples
Input: ["basic",42]
Output: 42
Hints
Related Problems

Function.prototype.bind Polyfill

Implement myBind — a polyfill for Function.prototype.bind that returns a new function with a bound `this` and optionally pre-filled arguments.