Tab Atkins Jr. (2015-06-02T15:51:47.000Z)
On Tue, Jun 2, 2015 at 8:45 AM, Benjamin Gruenaum <benjamingr at gmail.com> wrote:
> Thanks Domenic,
>
> Elaborating on your example with more details. Let's say you need to make
> sure at a certain point that an object has not been tinkered with by user
> code (for security reasons). You can't check the prototype or a symbol since
> those can be faked and you can't keep a regular `Set` because that would
> prevent any `Foo` object from ever being garbage collected.

Exactly.  WeakSet's use-cases are all in the same family as WeakMap,
just with a simpler set-up - rather than associating arbitrary data
with the object, you just associate "is in this set" with it.

~TJ
d at domenic.me (2015-06-08T00:00:44.043Z)
Exactly.  WeakSet's use-cases are all in the same family as WeakMap,
just with a simpler set-up - rather than associating arbitrary data
with the object, you just associate "is in this set" with it.