Removal of WeakMap/WeakSet clear

Andreas Rossberg rossberg at google.com
Thu Nov 27 07:17:51 PST 2014


On 27 November 2014 at 15:58, Andrea Giammarchi
<andrea.giammarchi at gmail.com> wrote:
> On Thu, Nov 27, 2014 at 2:44 PM, Andreas Rossberg <rossberg at google.com>
> wrote:
>> Well, there is no functionally correct polyfill for WeakMaps that is
>> actually weak, regardless of .clear.
>
> Please bear with me so I understand your point: if you have `o1` and `o2`
> and `o1.link = o2;`, wouldn't `o2` be "free" once `o1` is not referenced
> anymore ?

Yes, but this approach only works for regular, extensible, writable
objects o1, i.e., fails for frozen or sealed objects, proxies, etc.
And of course, as a polyfill for weak maps, it breaks other things,
such as correctly iterating over properties of an object used as a
key.

/Andreas


More information about the es-discuss mailing list