Javascript flatten on property

Date: 2021-06-18
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: [{}, {}] }]);
51230cookie-checkJavascript flatten on property