const arr = [{title: 'test', id: 1, children: []}, {title: 'test1', id: 2, children: [{title: 'first children', id: 3}]}]
arr.map((item, index) => {
item.children.map((ch_item, ch_index) => {
if (ch_item.id === 3) item.children = [];
})
})
item.children.map((ch_item, ch_index) => {
if (ch_item.id === 3) item.children = [];
})
у меня вернул тайп и по id = 1/3/12/15, по несуществующему id уже undefined, что ожидаемо