The ES6 draft specifies that `map()`, when applied to a typed array,
yields another instance of that same type. For converting between
array types, the `from()` method is added:
var f1 = new Float32Array();
...
var f2 = f1.map(x => x * 2); // Yields Float32Array
var i1 = Int32Array.from(f, x => x * 2); // Yields Int32Array
This is nice. However, there are some small differences between
the two that I think ought to be aligned.
In particular, `map` supplies its closure with three arguments: the
Element (`this[i]`), Index (`i`), and Collection (`this`). The index
is particularly useful, since you can write things like:
var f3 = f1.map((e, i) => e + i)
It seems that `from` only supplies the E argument though and not the I
and C. I propose this be changed to match `map()`.
Niko
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss