js去除json对象数组中的重复元素

let data = https://www.it610.com/article/[
{id:"123",name:"a"},
{id:"12",name:"b},
{id:"123",name:"c"},
]
let userIds = [];

data.forEach(d => { //id:相同的去掉,去重 if (userIds.indexOf(d.id) < 0) { userIds.push({ id: d.id, name: d.name }) } })

【js去除json对象数组中的重复元素】userIds = [{id:"123",name:"a"},{id:"12",name:"b}]

    推荐阅读