arrows and a proposed softCall

Russell Leggett russell.leggett at
Tue Jun 5 12:06:24 PDT 2012

On Tue, Jun 5, 2012 at 2:30 PM, Angus Croll <anguscroll at> wrote:

> Yes the thread needs wrapping up. Maybe I can attempt summarize the
> dilemma - with a question:
> Is call/apply just a remedy for non-lexical this assignment? Or is it a
> powerful feature in it own right.
> I'm with the second camp, but I think I'm in the minority in this list

Call/apply are of course powerful features, but they should not be used
just for the sake of using them. You know what's cleaner looking than
call/apply? Just calling the function directly!

I think the bigger, but related question is, "When should dynamic |this| be
used?" Do you think the jQuery style of using the dynamic this in callback
is good? Many of us here do not. Dynamic |this| allows for functions to
work like methods - it enables mixins and all kinds of meta-programming
goodness. However, it can also be abused, and create really funky code that
can lead to weird surprises.

Maybe I'm just conservative here. I suppose I can see the appeal of not
having to add that pesky extra parameter and instead use |this| for
whatever arbitrary thing you might want to put there, but it sure seems
less readable to me. You might as well just use the arguments object for
everything instead having parameter names!

Until now, with the addition of bind, and the fat arrow, there were a lot
of common cases where you would have to put a callback method back with its
original |this| object. That is one use of call/apply, and one that will
hopefully need less use. Another nice use of it was to easily delegate by
using apply and passing through the arguments object. That will go away
with rest parameters. So yeah, we might be seeing less of call/apply with
ES6, but I think we're replacing them with better patterns instead of just
saying they aren't useful anymore.

- Russ
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list