Can you write a function that deeply flattens an array?
Anónimo
Depending on how the non-arrays must be handled, this function does the job if you can just return the argument when it's not an array: function flatten(array) { if (!Array.isArray(array)) { return array; } return array.reduce((acc, cur) => { return acc.concat(flatten(cur)); }, []); }