Non-extensible WeakMaps

Brendan Eich brendan at mozilla.org
Sun Jan 22 12:11:31 PST 2012


> Herby Vojčík <mailto:herby at mailbox.sk>
> January 22, 2012 11:42 AM
> David Bruant wrote:
>> I agree that Object.preventExtensions is defined as preventing addition
>> of new properties. Likewise, Object.freeze and Object.seal only act on
>> object properties (extended to private properties?).

No, we agreed the property visiting under freeze and seal does *not* 
affect private-object-named properties.

>> But the broader problem they are addressing is reducing the mutability
>> of objects. WeakMaps, maps and sets bring a new form of mutability which
>> cannot be implemented in the form of private properties (I think at
>> least). So the question is:
>>
>> Should Object.preventExtensions be extended to reduce WeakMaps, Maps and
>> Sets mutability? Likewise for Object.seal|freeze?
>
> It would be special case. I'd say no.

I agree so far as this goes.

Mark has thought deeply about this topic, with the use-case of 
preventing extensions being the closing of covert or side channels in JS 
objects. For private names and weak maps, there is no channel to close 
via preventExtensions, since the attacker by definition doesn't have the 
key. For Maps and Sets, which support enumeration, the thread model is 
different.

/be


More information about the es-discuss mailing list