[JavaScript] How to flatten array of arrays?
I want to create an array of single dimension from the multi dimension arrays, how can I do that in Javascript?
1 Answer
3 years ago by Anusha
You can use either of the below approaches to flatten array of arrays into single array
1. Using flat()
arr.flat()
2. Using Concat() + reduce()
arr.reduce((acc, val) => acc.concat(val), [])
3 years ago by Meera