【发布时间】:2019-08-10 03:12:58
【问题描述】:
第一个数组如下:
var arr = [
{
key: 1,
title: 'aa',
children: [
{
key: 2,
title: 'bb',
children: [
{
key: 3,
title: 'cc',
children: [
{
key: 5,
title: 'ee',
children: [
{
key: 6,
title: 'ff'
},
{
key: 7,
title: 'gg'
},
{
key: 8,
title: 'hh'
}
]
}
]
},
{
key: 4,
title: 'dd',
}
]
}
]
}
]
console.log(arr)
如果第二个数组如下:
arr2 = [1, 2, 3, 4, 8]
那么我希望数组3如下:
arr3 = [4, 8]
【问题讨论】:
-
欢迎来到 Stack Overflow!请使用tour(你会得到一个徽章!),环顾四周,并阅读help center,尤其是How do I ask a good question? 我还推荐Jon Skeet 的Writing the Perfect Question
-
好的,所以你的前两个例子是有道理的,但是你开始谈论
If is the second array, then I expect the final array to be as follows这完全让我失去了。您能否详细说明这一点以及您期望如何获得arr3 -
@T.J.Crowder 喜欢您获得徽章! 了解人们进行巡回演出的好方法。 +1
-
@kemicofa - :-) 这确实意味着我每次都必须点击几下以确保他们还没有它,但我认为这是值得的。
-
请详细说明。我们不明白你想要什么。
标签: javascript node.js