|
|
|
|
|
by nikki93
3482 days ago
|
|
Haven't gone past the first slide yet, but FWIW with ES6 you could do something like: [nikki ~]$ node
> const bind = (fn, obj, ...args1) => (...args2) => fn.call(obj, ...args1, ...args2)
undefined
> bind(console.log, console, 'a', 'b')('c', 'd')
a b c d
undefined
> // calls `fn` with `obj` as `this` and the remaining arguments prepended with given ones
I believe all of the old-style argument stuff with `arguments` is possible with `...`, not sure though, maybe some edge cases. |
|