Class expressions in object initializers.
Bergi
a.d.bergi at web.de
Thu Jul 14 06:47:00 UTC 2016
/#!/JoePea schrieb:
> A use case could be to dynamically name a class at runtime without `eval`.
> `let o = { [name]() {} }` produces a named function inside of `o` (at least
> in Chrome) without needing eval, and then we can extract it from the object.
If you just want to name a class, there are much easier ways to do that:
let x = class {
get name() {
return dynamicName;
}
…
};
or
class x {
…
}
Object.defineProperty(x, "name", { value: dynamicName });
Kind regards,
Bergi
More information about the es-discuss
mailing list