Map/Set/WeakMap constructor genericity
jason.orendorff at gmail.com
Fri Nov 2 08:54:25 PDT 2012
In the draft spec, you can basically turn any arbitrary object into a Map.
var obj = new Date;
Map.prototype.set.call(obj, "x", "y");
assert(Map.prototype.get.call(obj, "x") === "y");
The same object can be a Set too. Why not?
assert(Set.prototype.has.call(obj, "z"), true);
This is intended to make Map/Set/WeakMap subclassable, which is fine. But
can we specify that without exposing Map initialization as a primitive that
users can apply to arbitrary objects?
As specified, a single object can have [[MapData]] and [[WeakMapData]] and
[[SetData]]. This is a pain to implement, and I don't see the benefit to
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss