1var multiDimensionArray = [["a"],["b","c"],["d"]]; //array of arrays
2var flatArray = Array.prototype.concat.apply([], multiDimensionArray); //flatten array of arrays
3console.log(flatArray); // [ "a","b","c","d"];
1
2
3
4
5 const numbers = [1, 2, [3, 4, 5, [6, 7]]];
6const flatNumbers = numbers.flat(2);
7
8console.log(flatNumbers);
1const arrays = [
2 ["$6"],
3 ["$12"],
4 ["$25"],
5 ["$25"],
6 ["$18"],
7 ["$22"],
8 ["$10"]
9 ];
10const merge3 = arrays.flat(1); //The depth level specifying how deep a nested array structure should be flattened. Defaults to 1.
11console.log(merge3);
12