Flatten the array of the array

If the array contains nested arrays we can make it as flat using infinity in flat

var array = [123, 500, [1, 2, [34, 56, 67, [234, 1245], 900]], 845, [30257]]
//flatten array of array
array.flat(Infinity)
// output:
// [123, 500, 1, 2, 34, 56, 67, 234, 1245, 900, 845, 30257]

Leave a comment

Your email address will not be published. Required fields are marked *