Skip to content
JavaScript utilities · Senior · about 15 minutes

Bind

Implement bind(fn, thisArg, ...partial) without Function.prototype.bind (the tests remove it). The returned function calls fn with this set to thisArg, with the partial arguments first and the call's own arguments after them. Calling the returned function as a method of another object must not change this. In the tests fn returns [this.name, ...arguments].

Start from

function bind(fn, thisArg, ...partial) {
  // Return a function that always calls fn with thisArg.
}

Hints and solution

Solve it in the app: its tests run without a year.

The hints, the solution and what an interviewer looks for opens with a year in the app. What a year includes