combine array of arrays js code example
Example 1: js convert array of arrays to array
// Converts array with multiple values into a single array with all items:
var merged = [].concat.apply([], arrays);
Example 2: array flatten
const arr = [1, 2, [3, 4]];
// To flat single level array
arr.flat();
// is equivalent to
arr.reduce((acc, val) => acc.concat(val), []);
// [1, 2, 3, 4]
// or with decomposition syntax
const flattened = arr => [].concat(...arr);