Binding arrow functions.

Erik Arvidsson erik.arvidsson at gmail.com
Mon Sep 1 11:35:16 PDT 2014


V8 is implementing arrow functions at the moment so they are
incomplete/incorrect. We have not enabled them yet and using the
experimental flags will lead to incomplete and incorrect behavior.


On Mon, Aug 25, 2014 at 6:23 AM, Mark Everitt <mark.s.everitt at gmail.com>
wrote:

> I got my lack-of-sleep addled head around this by realising that an arrow
> function performs like an immediately bound function expression:
>
> ```js
> var test = (function (){
>     // Do stuff with this...
> }).bind(this);
> ```
>
> i.e. Domenic's second example function. Then it was obvious that arrow
> functions are not really throwing anything new into the mix with regard to
> bind, apply, and call.
>
>
> On 25 August 2014 10:54, Till Schneidereit <till at tillschneidereit.net>
> wrote:
>
>> On Mon, Aug 25, 2014 at 4:30 AM, Boris Zbarsky <bzbarsky at mit.edu> wrote:
>>
>>> On 8/24/14, 10:26 PM, Mark Everitt wrote:
>>>
>>>> The problem remains that arrow functions make
>>>> bind etc. unpredictable.
>>>>
>>>
>>> I think part of Domenic's point is that return values of bind() also
>>> make bind (and call/apply for that matter) unpredictable.
>>>
>>
>> More fundamentally, I guess you could say that every function that
>> doesn't use `this` makes `bind` unpredictable. Domenic's second example
>> shows a function like that.
>>
>> I would argue that, if anything, arrow functions slightly improve
>> predictability: before arrow functions, the only way to meaningfully
>> "predict" the change in behavior that `bind` causes for a functions was by
>> looking at its source code *and by ensuring that the function hasn't been
>> bound already*. For arrow functions, you only need to inspect the source
>> code. (Granted, this probably isn't *that* much of a real-world
>> improvement.)
>>
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
>


-- 
erik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140901/ec5ecfe2/attachment.html>


More information about the es-discuss mailing list