Flattening a 2 Dimensional Array

Gotten from http://stackoverflow.com/a/10865042/4133302

by Luis Perez

JavaScript

// Given an 2D array of format [1,2,[3,4],[5,6]] ~> [1,2,3,4,5,6]
// Merges the array
function flatten2D(Array2D) {
  let flattened = [].concat.apply([], Array2D);
  return flattened;
}