У меня есть и объектный литерал, который по существу является деревом, которое не имеет фиксированного количества уровней. Как я могу искать дерево для частица node, а затем возвращать это node, если вы найдете в javascript эффектно?
По существу у меня есть дерево, подобное этому, и хотелось бы найти node с заголовком "randomNode_1"
var data = [
{
title: 'topNode',
children: [
{
title: 'node1',
children: [
{
title: 'randomNode_1'
},
{
title: 'node2',
children: [
{
title: 'randomNode_2',
children:[
{
title: 'node2',
children: [
{
title: 'randomNode_3',
}]
}
]
}]
}]
}
]
}];