"Subclassing" basic types in DOM - best method?

Brendan Eich brendan at mozilla.com
Mon Nov 19 21:46:06 PST 2012

Tab Atkins Jr. wrote:
> If we did this, the only reason to continue subclassing Map is to get
> instanceof checks to work.  Is this acceptable?

I think it's either irrelevant (no one tests 'aUrlQuery instanceof Map') 
or else a potential problem (cross-frame instanceof).

>    Are there better
> ways, perhaps on the horizon?  Any other thoughts?

Testing whether something quacks like a duck has not been on the agenda 
since ES4's like, which had other issues (as an annotation, arguably not 
so much as an operator). Just testing for properties, even testing their 
values against certain "types", is perhaps not enough to deduce Map-ness 
or (in the case of urlQuery) string->string Map-ness.

We can let people develop protocols, functional predicate APIs, for 
this. Or we could try to preload some as built-ins. I fear any committee 
shooting once, hitting some target somewhere, and pushing that into the 

Where I would like to go, if you force me to pick a promising path:



More information about the es-discuss mailing list