Thoughts on WeakMaps

David Bruant david.bruant at
Mon Jun 6 14:46:59 PDT 2011

Le 06/06/2011 17:41, Mike Samuel a écrit :
> 2011/6/6 David Bruant <david.bruant at>:
>> The consequence of this second point is wondering whether it's a good idea
>> to standardize WeakMap (instead of Map) at all.
> Besides a lack of out-of-memory errors and performance, a program
> using an object key map that doesn't use ephemeron pairs shouldn't
> behave differently than one that does.  But developers need to have
> some idea of memory performance when choosing an appropriate
> collection.  If you're documenting, I would document the behavior
> around GC upon which devs can rely.
Not only there is a memory performance difference, but also a key
enumerability difference. With WeakMaps, keys cannot be enumerated in a
determinist manner while they can with Map.


More information about the es-discuss mailing list