数组对象去重
需求数组对象去重
[{key
:1,name
:'哈哈'},{key
:2,name
:'鹤鹤'},{key
:1,name
:'哈哈'}]
function reduceData(data
){
let obj
= {}
let arr
= data
.reduce(function(item
,next
){
obj
[next
.item_id
] ? '' : obj
[next
.item_id
] = true && item
.push(next
)
return item
},[])
return arr
}
转载请注明原文地址: https://mac.8miu.com/read-502151.html