js convert array of arrays to array 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);

Here is what the above code is Doing:
1. The first line creates an empty array.
2. The second line uses the concat() method to merge the arrays.
3. The third line uses the apply() method to pass the arrays as arguments to the concat() method.

Similar Posts