Object id, hash, etc?

Brendan Eich brendan at mozilla.org
Fri Sep 11 18:01:41 UTC 2015

Tab Atkins Jr. wrote:
>   Using a primitive string as a key can
> inadvertently leak the value for a long time, as the key might be
> interned and long-lived, far past the point when your code has dropped
> the intended references to it.

Indeed. Strings do not have observable reference semantics at all, so 
any WeakMap accepting a "foo" key would have to keep the entry alive 
forever, as "foo" could be uttered by later code. Same for 42 ;-). You 
might think primitives could be live or dead but only objects are like that.


More information about the es-discuss mailing list