3 ms·
Are you not talking about a class instance? shouldn't all of this initialization happen inside of the constructor? If we're talking only about static propertie
by drenvuk 5y ago
Are you not talking about a class instance? shouldn't all of this initialization happen inside of the constructor?
If we're talking only about static properties it seems more reasonable to me to freeze them upon definition or first use.
- inbx0 5y agoThe const t = new Translation was indeed a mistake in my example, since we are talking about static properties and not instance properties. But the point still stands, just remove "new" from that example and the same applies, the getter-based approach creates new objects each time. > it seems more reasonable to me to freeze them upon definition or first use I agree, and that's why I'd default to static translations = {blah: things} and not static get translations() { return {blah: things} } the latter does not "freeze" them