one day of code

Flatten the array of unknown depth level to single dimension

January 04, 2021

[[[[[1, 2],[3, 4]],[5, 6]],[7, 8]],[9, 0]].flat(Infinity);
// [1, 2, 3, 4, 5, 6, 7, 8, 9, 0]

Written by Milan Miljkovic — a tech enthusiast and design system practitioner.