Get rid of arguments for bindKey

This commit is contained in:
Siarhei
2018-08-10 11:40:33 +04:00
parent e99d4cef84
commit c3015e47fc
2 changed files with 3 additions and 9 deletions

View File

@ -3,13 +3,10 @@
Creates a function that invokes the method at a given key of an object, optionally adding any additional supplied parameters to the beginning of the arguments.
Return a `function` that uses `Function.apply()` to bind `context[fn]` to `context`.
Use `Array.concat()` to prepend any additional supplied parameters to the arguments.
Use spread operator to prepend any additional supplied parameters to the arguments.
```js
const bindKey = (context, fn, ...args) =>
function() {
return context[fn].apply(context, args.concat(...arguments));
};
const bindKey = (context, fn, ...boundArgs) => (...args) => context[fn].apply(context, [...boundArgs, ...args]);
```
```js