Za: http://www.jstips.co/en/flattening-multidimensional-arrays-in-javascript & https://www.javascriptjanuary.com/blog/writing-maintainable-and-readable-javascript-design-patterns
var myArray = [[1, 2],[3, 4, 5], [6, 7, 8, 9]]; // we want to achieve: [1, 2, 3, 4, 5, 6, 7, 8, 9]
//#1
var myNewArray = [].concat.apply([], myArray);
//#2 solution is less performant
var myNewArray = myArray.reduce(function(prev, curr) {
return prev.concat(curr);
});
//#3 with ES6 and spread operator
var myNewArray = myArray.reduce((acc, it) => [...acc, ...it], []);