Recent | Popular
#javascript #flatten #array
const nestedArray = [1, [2], [[3], 4], 5]; const flatten = nestedArray => nestedArray.reduce( (flat, item) => flat.concat(Array.isArray(item) ? flatten(item) : [item]), [] ); flatten(nestedArray);
#lodash #javascript #flatten
const recurse = (rows) => _.map((rows), (row) => row.collapsed ? [row] : [row, recurse(row.children)]); const flattenTree = tree => _.flattenDeep(recurse(tree));
Wed Apr 05 2023 22:15:04 GMT+0000 (Coordinated Universal Time) https://codetogo.io/how-to-flatten-a-nested-array-in-javascript/
Sat Aug 27 2022 13:26:17 GMT+0000 (Coordinated Universal Time)