DEV Community

Discussion on: The Complete Guide to Using Arrays in JavaScript

Collapse
 
jannikwempe profile image
Jannik Wempe

Thanks for that awesome overview. Good job!

Just a question: Your are writing;

Array.flat function does not do a good job of recursively flatten arrays.

Can you give an example? Because your examples of course can be flattend by Array.flat():

let arr2 = [1, 2, [3, 4], [5, [6,[7,]]]];
arr2.flat(Infinity)
// (7) [1, 2, 3, 4, 5, 6, 7]
Collapse
 
aumayeung profile image
John Au-Yeung

Thanks so much for reading.

I was thinking about the finite cases. I think I should correct that.