根据数组对象中某个属性去重
let newTags = tags.reduce(function (tmpArr, item) {
if (tmpArr.findIndex((tmp) => tmp.name === item.name) === -1) {
tmpArr.push(item)
}
return tmpArr
}, [])
根据数组中元素去重
let newList = list.filter(function (item, index) {
return list.indexOf(item) === index
})
标签:tmp,index,function,tmpArr,js,item,数组
From: https://www.cnblogs.com/sglblog/p/16695637.html