arrow function syntax simplified
brendan at mozilla.org
Thu Mar 29 12:02:18 PDT 2012
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.
This makes arrows like built-ins. They're still functions, per my other
I'll update the strawman (which should be promoted shortly).
Thanks for the good questions!
More information about the es-discuss