From e726ed14dbc909b1ef53ead0bfff5156864f280e Mon Sep 17 00:00:00 2001 From: Siarhei Date: Thu, 9 Aug 2018 11:50:24 +0400 Subject: [PATCH] Get rid of arguments for bind --- snippets/bind.md | 5 +---- test/bind/bind.js | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) 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;