I have a tree structure going like this:
public folders: any[] = [
{name : 'Inbox', id : 1, folders : []},
{name : 'Draft', id : 2, folders : []},
{name : 'Spam', id : 3, folders : []},
{name : 'Trash', id : 4, folders : [
{name : 'Trash lvl 1', id : 5, folders : [
{name : 'Trash lvl 2', id : 6, folders: []}
]}
]},
];
After that I'll get some list of indexes, going like this:
var ids = [3, 0, 0];
What would be the most effective JavaScript/TypeScript way of selecting following object:
{name : 'Trash lvl 2', id : 6, folders: []}
So I need something like this, only dynamically:
console.log(this.folders[3]['folders'][0]['folders'][0]);