WeakMap API questions?

Erik Arvidsson erik.arvidsson at gmail.com
Fri Aug 13 23:22:59 PDT 2010


I have a few questions regarding the WeakMap API.

1. Why isn't there a way to check for presence of a key (using has/contains)?

Given that undefined is a valid value it is not sufficient to just
return undefined for get


2. Why isn't there a way to remove a key-value-pair?

Setting the value to undefined is not the same.


3. Why isn't there a way to iterate over the keys?

I can see that this might be a security issue but iteration is useful
and security sensitive code can prevent iteration in several ways.


4. Why does set throw if the key is not an object but get doesn't?

Same would go for delete and has if those are added.

-- 
erik


More information about the es-discuss mailing list