4 ms·
> it has weak keys, not weak values. Wow. That does seem backwards. What's the use-case for that sort of thing?
by qu4z-2 13y ago
> it has weak keys, not weak values.
Wow. That does seem backwards. What's the use-case for that sort of thing?
- pixelcort 13y agoThe weak keys is nice as it gives you a place to put "hidden" properties that can only be accessed when combining an object and the WeakMap. When the object is GC'd, the hidden properties in the WeakMap can as well. But you can get close using a naming convention on the objects proper, say double underscore prexix or whatnot. What can't be easily approximated right now is weak values, for identity maps in particular.