js对象数组去重
对象数组去重
方法1:
// key为对象的某个字段的key
removeDuplicationData(arr, key) {
const obj = {}
arr = arr.reduce((item, next) => {
obj[next[key]] ? '' : (obj[next[key]] = true && item.push(next))
return item
}, [])
return arr
}