let filter_arrObj = [];
let arrObj = [
{
name: 'xiaoqing',
age: 15,
sex: 0
},
{
name: 'xiaoming',
age: 12,
sex: 0
},
{
name: 'xiaobai',
age: 21,
sex: 0
},
{
name: 'xiaoqing',
age: 25,
sex: 0
},
]
filter_arrObj = arrObj.filter((item, index, origin) =>
index === origin.findIndex(itemInner => {
return itemInner.name === item.name
}
))
findIndex() 方法返回传入一个测试条件(函数)符合条件的数组第一个元素位置。只返回第一个满足条件的索引值