Array subclassing, .map and iterables (Re: Jan 30 TC39 Meeting Notes)

Allen Wirfs-Brock allen at
Mon Feb 11 10:27:55 PST 2013

On Feb 10, 2013, at 1:04 PM, Tab Atkins Jr. wrote:
> From what I've seen in the examples in this topic so far, it looks
> like Array#from takes a second optional argument, which is a function
> that you map the iterable elements through first, before giving them
> to the constructor.  So, you would write:
> NodeList.from( ["div", "span", "p"],
> (nodeName)=>document.createElement(nodeName) );


Of course, in defining 
       class NodeList extends Arrar {...}
 you could decide to over-ride the inherited definition of .from with a version that implicitly did the above coercion on string valued elements.  It up to the designer of the class interface.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list