Get the latest tech news
JavaScript weakmaps should be iterable
wingolog: article: javascript weakmaps should be iterable
When WeakMap was added to JavaScript, back in the ES6 times, some implementors thought that it could be reasonable to implement weak maps not as a data structure in its own right, but rather as a kind of property on each object. GC would be free to notice dead maps and remove their associations in live objects. As with many things GC-related, non-iterability of weak maps then gained a kind of legendary status: the lore states that non-iterability preserves some key flexibility for JS implementations, and therefore it is good, and you just have to accept it and move on.
Or read this on Hacker News