what kind of problem is this fat arrow feature trying to solve ?

Andrea Giammarchi andrea.giammarchi at gmail.com
Tue Oct 1 19:35:28 PDT 2013


setTimeout accept extra arguments ... I write JavaScript that uses this
feature.

`setTimeout(callback, delay, arg1, arg2, argN, evenAnObject);`

so fat arrow does not solve much here, I can use self as first argument and
I am good.

`forEach` and all other arrays accept a second argument

`array.forEach(doStuff, boundContextObject);`

so fat arrow does not solve a thing in mostly all Array extras.

for **DOM** I use handlers as specified by **W3C** so that `{handleEvent:
function () {this}}` works better than any mess I could create with
callbacks that I won't be unable to remove later on (as I've said) ... so I
can use `removeEventListener(this)` in every method handled by that object.

So I actually wonder what kind of JavaScript **you** write because this was
a honest question but probably ... people not familiar with JS are the
answer: since developers ignore part of JS specs available since every then
we need a fat arrow to break old syntax to make the creation of self bound
function easier.

This would be already an answer so thanks for participating.

br




On Tue, Oct 1, 2013 at 3:47 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:

> On Tue, Oct 1, 2013 at 3:43 PM, Andrea Giammarchi
> <andrea.giammarchi at gmail.com> wrote:
> >   4. what kind of problem is this fat arrow feature trying to solve
> exactly,
> > if it cannot be used for classes, direct methods assignment, but only for
> > some runtime event assignment instead of using bind and still being
> unable
> > to remove that listener later on ?
>
> I'm not sure what sort of JS you write, but anonymous functions that
> don't need standard 'this' binding are used in *lots* of places, far
> beyond just "runtime event assignment".  Have you never used
> setTimeout, forEach, map/reduce/etc, and all the
> callback/Promise-based features of DOM/etc?
>
> ~TJ
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20131001/e00ad4e1/attachment.html>


More information about the es-discuss mailing list