arrow function syntax simplified
Rick Waldron
waldron.rick at gmail.com
Fri Mar 30 05:31:45 PDT 2012
On Friday, March 30, 2012 at 6:03 AM, Marius Gundersen wrote:
> > Indeed lexical |this| means you can't pass a wrong-this even via .call or .apply. Thanks,
>
> Isn't this a bad idea? Take for example the very common jQuery callback method, which would look like this:
>
> $("img").on("click", e => $(this).hide());
>
> jQuery (and many other frameworks) do a lot of things with |this| behind the scenes, where it would be very nice to have |this| be set by the framework.
jQuery provides the same |this| value that you'd get using addEventListener, so this issue would exist in the DOM as well.
More pointedly, lexical |this| prevents modifying |this| via apply and call
I had hoped for thin arrow to lighten the keystroke load here.
Rick
> Or is the consensus that the current way of doing this is not good, and should be discurraged?
>
> Marius Gundersen
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120330/461b420b/attachment-0001.html>
More information about the es-discuss
mailing list