Why does Array.from also take a mapFn?

Brandon Benvie bbenvie at mozilla.com
Mon Jun 24 09:44:08 PDT 2013


On 6/24/2013 9:42 AM, Domenic Denicola wrote:
>> That led to further discision of that usage and we got into things like the last example:
>>
>> ```js
>> // Turn an array of nodeNames into NodeList of nodes
>> NodeList.from( ["div"], node => document.createElement(node) );
>> ```
> I think I must be missing something. Why is this superior to
>
> ```js
> NodeList.from(["div"].map(node => document.createElement(node));
> ```

Using `NodeList.from` returns a NodeList. NodeList.from(...).map(...) 
returns an Array.


More information about the es-discuss mailing list