I have this array:
[
{
id: 1,
name: 'test 1',
children: []
},
{
id: 2,
name: 'test 2',
children: [
{
id: 4,
name: 'test 4'
}
]
},
{
id: 3,
name: 'test 3',
children: []
}
]
How can I filter by the id
property in both this array and the nested children
arrays?
For example, searching for id = 3
, should return the test 3
object, and searching for id = 4
should return the test 4
object.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…