On Tue, Oct 7, 2014 at 4:08 PM, Claude Pache <[email protected]> wrote:
> > Le 7 oct. 2014 à 23:43, Dmitry Soshnikov <[email protected]> a > écrit : > > On Tue, Oct 7, 2014 at 2:35 PM, Tab Atkins Jr. <[email protected]> > wrote: > >> On Tue, Oct 7, 2014 at 2:26 PM, Dmitry Soshnikov >> <[email protected]> wrote: >> > I see. Actually it doesn't work, your're correct, since >> > `Array.prototype.map` does preserve the kind (at least in the latest >> draft). >> >> Hmm, per Rick's earlier email and >> < >> https://github.com/rwaldron/tc39-notes/blob/c61f48cea5f2339a1ec65ca89827c8cff170779b/es6/2013-01/jan-30.md#revising-the-array-subclassing-kind-issue >> >, >> Array#map (used by a subclass) doesn't preserve the subclass's type; >> it always returns an Array. >> >> > And the `UInt32Array.from(...)` would be consuming a nodeList, not an >> array. >> > Will the `nodeList.map(node => parseInt(node.value, 10));` by itself >> > actually work then? >> >> If .map() is inherited from Array, and thus not type-preserving, yes, >> it'll work. >> >> > Yes, it is preserving (probably was changed since that previous > discussion), see (9) in > http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.map. > Will a simple map to `node.value` on a `NodeList` work with the preserving > `Array#map`? > > > So, a `SortOfArray.from` (with a mapping) is finally less confusing than a > `SortOfArray#map`, > for you don't have to look at the doc in order to determine the type of the > result... :-p > > Also related, and came on Twitter just not: https://twitter.com/DmitrySoshnikov/status/519964146637737986 The mapping function from `Array.from` considers holes (from the new TC39 "policy"), but `Array#map` does not. I guess this doc on `Array.from` from MDN [1] should be fixed then: > More clearly, Array.from(obj, mapFn, thisArg) is the same as Array.from(obj).map(mapFn, thisArg), except that it does not create an intermediate array. Since not only they are "the same" (as we confuse/substitute pre- and post- mapping), but also the mapping function itself behaves differently. [1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from Dmitry
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

