Non-extensible WeakMaps

Tab Atkins Jr. jackalmage at gmail.com
Sun Jan 22 11:16:21 PST 2012


On Sun, Jan 22, 2012 at 10:28 AM, David Bruant <bruant.d at gmail.com> wrote:
> Hi,
>
> In Firefox Aurora as well as in Chromium 18, running the following
> -----
> var wm = new WeakMap();
> var o = {};
>
> Object.preventExtensions(wm);
>
> wm.set(o, 1);
> console.log(wm.get(o)); // 1
> -----
>
> Is this something that is wanted?
> Same question for Maps and Sets.

Calling set() on a WeakMap doesn't add any properties to the WeakMap
object, so yes, it's expected that preventExtensions has no effect.

~TJ


More information about the es-discuss mailing list