"Subclassing" basic types in DOM - best method?

Rick Waldron waldron.rick at gmail.com
Wed Nov 21 11:51:00 PST 2012

On Wednesday, November 21, 2012 at 3:40 AM, Brendan Eich wrote:

> Tab Atkins Jr. wrote:
> > > let o = { items: function() {} };
> > > > 
> > > > would pass that test.
> > 
> > I'm not sure how else you're supposed to detect iterables.
> It's not 'items', btw. The iterator-getter/maker is named 'iterator' in 
> SpiderMonkey currently, and last I heard would be @iterator (well-known 
> public symbol) in ES6.
> As with most duck typing, you're right and I think Rick is picking on a 
> non-issue:

I wish that were true, but I share that from user code I've encountered in the  jQuery bug tracker history. Devs make objects that have a "length" property and don't understand why their object gets array treatment when passer to library code (less common these days and arguably a mistake in the duck-typing itself) or an object with a numeric nodeType property that gets mistaken for a DOM node. 

...Most of this stuff is facepalm inducing :(

> there's no point worrying about the halting problem. Just 
> call the quack function and let the chips fall where they may ;-).
> /be 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121121/7a387d82/attachment.html>

More information about the es-discuss mailing list