diff --git a/snippets/bind.md b/snippets/bind.md index c0a9402e2..7cfa58564 100644 --- a/snippets/bind.md +++ b/snippets/bind.md @@ -6,10 +6,7 @@ Return a `function` that uses `Function.apply()` to apply the given `context` to Use `Array.concat()` to prepend any additional supplied parameters to the arguments. ```js -const bind = (fn, context, ...args) => - function() { - return fn.apply(context, args.concat(...arguments)); - }; +const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); ``` ```js diff --git a/test/bind/bind.js b/test/bind/bind.js index e7252bd64..e764a4cc2 100644 --- a/test/bind/bind.js +++ b/test/bind/bind.js @@ -1,5 +1,2 @@ -const bind = (fn, context, ...args) => - function() { - return fn.apply(context, args.concat(...arguments)); - }; +const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); module.exports = bind;