Usage for weak-maps

P T Withington ptw at pobox.com
Fri Oct 29 08:33:35 PDT 2010


On 2010-10-29, at 04:50, Peter van der Zee wrote:

> What's the use case for weak maps? What would you do with it that currently
> impossible and why is the workaround (if any) problematic enough to warrant
> a weak map implementation?

Another use case was mentioned in the "New topic regarding Proxies: intercession for ===" thread.  If you want to write a value type, the constructor needs to return the same object for identical parameters for === to work, which means it needs a table of all the objects it has ever made, but it doesn't need (or want) to hang on to objects that are no longer in use.  [The alternative being discussed in the proxy thread is to be able to customize === to give the same illusion.]


More information about the es-discuss mailing list