前端对象数组,根据对象的某个字段进行去重
datas: [
{
name: 'liu',
type: '1'
},
{
name: 'wang',
type: '2'
},
{
name: 'wang',
type: '1'
}
]
const rr = new Map()
const datas = datas.filter((a) => !rr.has(a.name) && rr.set(a.name, 1))