arrow function syntax simplified
Herby Vojčík
herby at mailbox.sk
Thu Mar 29 12:33:49 PDT 2012
Brendan Eich wrote:
> Brendan Eich wrote:
>> Irakli Gozalishvili wrote:
>>> Few questions on this new arrow functions:
>>>
>>> let foo = x => x * x
>>>
>>>
>>> 1. What is foo.prototype ?
>>> 2. What does new foo(y) does ?
>>
>> The idea with arrow function syntax (as opposed to block-lambda
>> revival) was to be as close to "just syntax" for functions. Obviously
>> we've made early-error restrictions but this design goal still stands.
>> So the answers are:
>>
>> 1. Same as for any user-defined function (a fresh Object instance).
>> 2. Same as for any user-defined function.
>
> Oops, I left off something important. Since we agreed on lexical |this|
> binding, there's no way for the new object to flow into the arrow
> function. So I'm wrong, the answers are:
>
> 1. Same as for any built-in function: no .prototype property at all.
> 2. Arrow-functions lack [[Construct]] so you cannot 'new' them.
Isn't also answer to "5.":
Q: Will foo.call, foo.apply pass in the `this` ?
A: Yes, see above.
changed? Or is lexical bound this working only for default this, but not
for call and apply?
> This makes arrows like built-ins. They're still functions, per my other
> answers.
>
> I'll update the strawman (which should be promoted shortly).
>
> Thanks for the good questions!
>
> /be
Herby
More information about the es-discuss
mailing list