flatten array node code example
Example 1: Javascript flatten array of arrays
var multiDimensionArray = [["a"],["b","c"],["d"]]; //array of arrays
var flatArray = Array.prototype.concat.apply([], multiDimensionArray); //flatten array of arrays
console.log(flatArray); // [ "a","b","c","d"];
Example 2: flatten nested array javascript
const arr2 = [1, 2, [3, 4, [5, 6]]];
arr2.flat();