【发布时间】:2015-08-15 17:24:28
【问题描述】:
下面我有一个arrary (arr) 包含objects 和两个属性id 和content,我需要映射到这个array 并返回和array,其中项目与相同的id 是数组中的shift,按从左到右的顺序排列。
var arr = [
{
'id': '32423423',
'content': ['one']
},
{
'id': '23456789',
'content': ['one', 'two', 'three']
},
{
'id': '23456789',
'content': ['one', 'two', 'three']
},
{
'id': '23456789',
'content': ['one', 'two', 'three']
}
{
'id': '13123123',
'content': ['two']
}
]
期望的输出是这样的:
var output = [
'one',
'one',
'two',
'three'.
'two'
]
content 项的数组。
【问题讨论】:
-
所以,基本上,您需要删除重复项,然后创建一个仅包含每个
content属性中剩余项的数组? -
不,我需要重复 @taylorc93 在下面查看我的答案
标签: javascript arrays object dictionary lodash