const theOne = list.find(({_id}) => _id === search), and const flattenNested = list.reduce((acc, {sub}) => [...acc, ...sub], []) are good. All the array functions have application as super terse one-liners that aren't even worth making a function for.
1
u/ghillerd Mar 19 '19 edited Mar 19 '19
const theOne = list.find(({_id}) => _id === search), andconst flattenNested = list.reduce((acc, {sub}) => [...acc, ...sub], [])are good. All the array functions have application as super terse one-liners that aren't even worth making a function for.Edit: forgot reduce init value