Use cases for WeakMap

Oliver Hunt oliver at apple.com
Sun May 15 15:48:58 PDT 2011


On May 15, 2011, at 3:47 PM, Boris Zbarsky wrote:

> On 5/15/11 2:20 PM, Rick Waldron wrote:
>> Thanks Brendan, I was looking for something that was representative of
>> Boris's use-case
> 
> A typical example is an extension wanting to associate some state with a DOM element or a Window without polluting the DOM.  For example, Adblock Plus wants to store some state per-element so that it knows when it's in the middle of unblocking something so it'll allow the load through for that one thing only.  Firebug wants to store some state per-window (e.g. script bodies, etc) and discard it when the window goes away.
Which is a use case private names would achieve much more succinctly than weakmaps.

--Oliver



More information about the es-discuss mailing list