arrow function syntax simplified
dmitry.soshnikov at gmail.com
Thu Mar 29 14:57:47 PDT 2012
On Thu, Mar 29, 2012 at 12:02 PM, Brendan Eich <brendan at mozilla.org> 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
>> 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.
Just a small note related to lexical `this' -- if it's just a syntactic
sugar for the `bind' method, then [[Construct]] probably should (for
consistency?) work, providing newly created object -- because a bound
function delegates to the target's [[Construct]] per ES5.
> 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!
> es-discuss mailing list
> es-discuss at mozilla.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss