Explorer
Node.js

Implement `myBind(fn, context, ...args)` that behaves like Function.prototype.bind.

Problem Statement

Implement `myBind(fn, context, ...args)` that behaves like Function.prototype.bind.

Complexity

Time Complexity: -

Space Complexity: -

Hints

šŸ’” Hint 1: bind() returns a new function with this set to context. šŸ’” Hint 2: Pre-fill some arguments and allow more to be passed when called. šŸ’” Hint 3: return (...laterArgs) => fn.apply(context, [...args, ...laterArgs]); āœ… Solution: ```javascript function myBind(fn, context, ...args) { return function(...laterArgs) { return fn.apply(context, [...args, ...laterArgs]); }; } ```

Implement Function.prototype.myBind

Hard
Implement `myBind(fn, context, ...args)` that behaves like Function.prototype.bind.
Editor
Loading Editor...
Evaluate code
Output:Click "Run" above to execute and verify your code here.
"Hello, Alice!"