数组对象去重

const  distinct = (arr, key) => {
for (let i = 0; i < arr.length; i++) {
  for (let j = i + 1; j < arr.length; j++) {
    if (arr[i][key] === arr[j][key]) {
      arr.splice(j, 1)
      j = j - 1
    }
  }
}
return arr
}

posted @ 2024-06-24 17:34  就这样,  阅读(4)  评论(0编辑  收藏  举报