reduce array concat after code example
Example 1: how to flatten array with reduce in javascript
let flattened = [[0, 1], [2, 3], [4, 5]].reduce(
function(accumulator, currentValue) {
return accumulator.concat(currentValue)
},
[]
)
// flattened is [0, 1, 2, 3, 4, 5]
Example 2: js convert array of arrays to array
// Converts array with multiple values into a single array with all items:
var merged = [].concat.apply([], arrays);