Closures & Functions
Implement Function.prototype.bind
mediumJS SpecificJS / TS3 tests
Problem Statement
Implement `myBind(fn, context, ...presetArgs)`, mimicking `Function.prototype.bind`. It must return a new function that binds `this` to `context` and prepends `presetArgs`.
Examples
Example 1:
function greet(punctuation) { return `Hello ${this.name}${punctuation}`; }
const bound = myBind(greet, { name: 'World' }, '!');
bound(); // 'Hello World!'JavaScript & TypeScript starter code included
Run this as a live interviewPractice solo
3 test cases. No second person needed.