Class expressions in object initializers.

Blake Regalia blake.regalia at gmail.com
Thu Jul 14 02:48:34 UTC 2016


What would be a use case for this?


 - Blake

On Wed, Jul 13, 2016 at 7:42 PM, Bergi <a.d.bergi at web.de> wrote:

> /#!/JoePea wrote:
>
> Might be nice to be able to do it with classes too:
>>
>> ```js
>> let dynamicName = "foo"
>> let o = {
>>   class [dynamicName] { /* ... */ }
>> }
>> console.log(o.foo) // logs the class
>> ​```​
>>
>
> You can already do
>
> let dynamicNAme = "foo";
> let o = {
>     [dynamicName]: class {
>>     }
> };
>
> but I can see absolutely no reason why you'd want to put a class inside an
> object literal.
>
>  Bergi
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160713/42637dbb/attachment.html>


More information about the es-discuss mailing list