A reference to a class is simply a variable. Variables only exist within a certain scope. When using a variable, its name is essentially irrelevant so long as you, the developer, understand what it refers to.
If its necessary to distinguish between multiple instances of an object that were created in response to an unpredictable input, then what you really need are *properties* (e.g., keys and values, where the keys reflect the 'dynamic' name), as Bergi points out. - Blake On Wed, Jul 13, 2016 at 11:47 PM, Bergi <[email protected]> wrote: > /#!/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 > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

