物件陣列去重
方法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
}
物件陣列去重
方法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
}