JavaScript WeakMaps are not actually weak: they refer strongly to their contents as long as the key is alive.
This brings the list of imprecisely-named ECMAScript APIs to:
Map → OrderedMap
Set → OrderedSet
Promise.race → Promise.anySettled
WeakMap → Ephemeron
-
-
Replying to @mathias
I'm now confused about what weak means
. What would you have to hypothetically change in WeakMap for it to be weak, and would it be useful functionality?2 replies 0 retweets 0 likes -
Replying to @davidmarkclem
It's just that a `WeakMap` only refers weakly to its contents once the key is garbage-collected. Until then, it refers strongly to its contents. `WeakRef`s are the more powerful, truly weak primitive that you really want. cc @ulandeg
@mlippautz5 replies 0 retweets 10 likes -
WeakRefs are often too powerful though. WeakMaps really should continue to be used for use cases where they are sufficient
1 reply 0 retweets 5 likes
Definitely. I’m not hating on WeakMaps — just on their name 
1:21 PM - 3 Jul 2019
0 replies
0 retweets
3 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
JavaScript, HTML, CSS, HTTP, performance, security, Bash, Unicode, i18n, macOS.