The answer to Javascript equivalent of Python's zip function shows a neat way of taking any number of arrays, and "zipping" them into a merged array in a single statement.
zip= rows=>rows[0].map((_,c)=>rows.map(row=>row[c]))
This question Javascript - Sum two arrays in single iteration shows a similar idea, but summing the entries as they're zipped up.
I'm wondering how to combine the two techniques - so given an unknown number of arrays:
[
[1,2,3],
[1,2,3],
[1,2,3]
]
... the result is [3, 6, 9]
, ie the sum of the first elements, the second and so forth. For the sake of simplicity, assume each array contains the same number of items.