(Weak){Set|Map} subclassing

David Bruant bruant.d at gmail.com
Tue Nov 27 13:47:12 PST 2012


Le 27/11/2012 19:40, Allen Wirfs-Brock a écrit :
> On Nov 27, 2012, at 5:07 AM, David Bruant wrote:
>> Le 27/11/2012 14:02, David Bruant a écrit :
>>> Hi,
>>>
>>>     var o = {};
>>>     WeakMap.call(o);
>>>     WeakSet.call(o);
>>>     Map.call(o);
>>>     Set.call(o);
>>>
>>> Currently, this works and makes o a weakmap, a weakset, a map and a set...
> Sort of.  They won't inherit from any of the corresponding prototype types so none of the relevant methods will be available on those objects.  However they could be explicitly invoked on the object.  If you want to make them all available then the individual methods would have to be installed with non-conflicting names.
>
> But overall, why should the above be a problem?  It is how ES "construction" works and the way things work for any user defined objects.  Why should built-ins be any different?
hmm... that is... a good argument :-)

David


More information about the es-discuss mailing list