WeakMaps question ?

Eric Jacobs eric.j at collava.org
Fri Nov 11 15:36:48 PST 2011


Irakli Gozalishvili wrote:
> I really need to know why WeakMaps don't accept primitives as keys, 
> can anyone please reply ?
>
How would the GC know when to remove the entry from the map? Because a 
primitive is never (or always, if wrapped) eligible for 
garbage-collection, a WeakMap does not help your use case.

A WeakMap will not give you your time-limited cache. You still have to 
implement that yourself.

-Eric



More information about the es-discuss mailing list