See my suggestion here: Provide an easy way to create a new array, filled via a mapping function - #37 by graphemecluster.
Btw, Array.prototype.nestedForEach
and Array.prototype.nestedMap
are good ideas too:
[5, 7]
.buildShape((i, j) => i * 7 + j + 1)
.nestedMap((point, [i, j]) => `Point #${point} is at (${i}, ${j})`)
.nestedForEach(message => console.log(message));
/* logs
Point #1 is at (0, 0)
Point #2 is at (0, 1)
……
Point #35 is at (4, 6)
*/