3 ms·
The 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 stil
by inbx0 5y ago
The
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