name anonymous functions on property assignments

Allen Wirfs-Brock allen at wirfs-brock.com
Sun Jul 26 20:37:26 UTC 2015


On Jul 26, 2015, at 1:17 PM, Jordan Harband wrote:

> What is the function's name if the computed object literal key is a Symbol? ie, what does the following output:

specified in step 4 of http://ecma-international.org/ecma-262/6.0/#sec-setfunctionname 

> 
> ```js
> const sym = Symbol('something');
> const o = {
>     [sym] () {}
> };
> console.log(o[sym].name);
> ```

should be:  "[something]"
> 
> Currently it appears Babel outputs an empty string for this case.
> 
> If the current spec handles symbols just fine in this way, why would "the possibility that the property key is a symbol" be a reason for an expression form not to set the "name" property?

Yes, the ES2015 spec. does say how to handle Symbols as `name` property values.

Allen


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150726/6f1a127b/attachment.html>


More information about the es-discuss mailing list