Class expressions in object initializers.
Bergi
a.d.bergi at web.de
Thu Jul 14 02:42:36 UTC 2016
/#!/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
More information about the es-discuss
mailing list