function flatten(list: any[]) { const result = []; function internalFlatten(list: any[]) { list.forEach(item => { result.push(item); internalFlatten(item.children); }); } internalFlatten(list); return result; } flatten([{ children: [{}, {}] }]);
512300cookie-checkJavascript flatten on property