Modified zip to use spread operator instead of Array.apply

This commit is contained in:
Justin Lee
2017-12-15 08:44:13 -08:00
parent 3c48c3b5d8
commit fd3ef95ab3

View File

@ -6,7 +6,7 @@ If lengths of the argument-arrays vary, `undefined` is used where no value could
```js
const zip = (...arrays) => {
const maxLength = Math.max.apply(null, arrays.map(a => a.length));
const maxLength = Math.max(...arrays.map(x => x.length));
return Array.from({length: maxLength}).map((_, i) => {
return Array.from({length: arrays.length}, (_, k) => arrays[k][i]);
})