Flatten Multidimensional Array Flashcards

1
Q
var myArray = [[1, 2],[3, 4, 5], [6, 7, 8, 9]];
We want [1, 2, 3, 4, 5, 6, 7, 8, 9];

Solution 1: Using concat() and apply()

var myNewArray =

A

var myNewArray = [].concat.apply([], myArray);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly