there any better way I can achieve this?
https://bin.mkr.pw/~5f8f276f1b923e285d89c8bc
What you mean by delete object? Just use Array#filter
Sorry I mean children will move above for example I have object like { title: "a", id: "a", children: [ { title: "ab", children: [], id: "ab", }, { title: "ac", children: [ { title: "acc", children: [], id: "acc", }, ], id: "ac", }, ], }; and If I want to remove object id 'ac' then expected output will be { title: "a", id: "a", children: [ { title: "ab", children: [], id: "ab", }, { title: "acc", children: [], id: "acc", }, ], };
The top-level object has a children prop
If you want to remove a then the children will move up?
That's kind of weird
Yet interesting
From what I see, you just wanna remove duplicate entries
use a data structure
I defined it
Обсуждают сегодня