Classes as Sugar -- old threads revisited

Mark S. Miller erights at
Tue May 26 18:17:25 PDT 2009

On Tue, May 26, 2009 at 3:08 PM, P T Withington <ptw at> wrote:

> These two are reversed, aren't they?  The const should have the getter
> rather than the value?
> On 2009-03-30, at 22:41EDT, Mark S. Miller wrote:
>        pubInstVar: {get: Object.freeze(function{return pubInstVar;}),
>>                    enumerable: true},
>>       pubInstConst: {value: pubInstConst,
>>                      enumerable: true}

No, it's correct as is. With an initialized const variable, its value can't
change, so we can just present the value directly as the value of a frozen
data property. A let variable, on the other hand, can continue to change.
Thus, in order for the property to continue to present the variable's
current value we need a getter.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list