vue数组对象如何去重复

数据格式如下:

let arr = [
    {
        "id": "46f7c6ba-b4ca-4843-b5d1-76399d1ac52a",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "S",
        "skuCode": "10",
        "skuName": "美年达1",
        "price": 10,
        "isShelf": "上架",
        "check": false
    },
    {
        "id": "2ea2a723-1a6c-4545-92ce-2ef07547642f",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "M",
        "skuCode": "11",
        "skuName": "可乐1",
        "price": 11,
        "isShelf": "上架",
        "check": false
    },
    {
        "id": "57bc93ad-84de-4737-8ca6-d6abe97eb9ae",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "L",
        "skuCode": "12",
        "skuName": "雪碧1",
        "price": 12,
        "isShelf": "上架",
        "check": false
    },
    {
        "id": "57bc93ad-84de-4737-8ca6-d6abe97eb9ae",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "L",
        "skuCode": "12",
        "skuName": "雪碧1",
        "price": 12,
        "isShelf": "上架",
        "check": false
    },
    {
        "id": "2ea2a723-1a6c-4545-92ce-2ef07547642f",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "M",
        "skuCode": "11",
        "skuName": "可乐1",
        "price": 11,
        "isShelf": "上架",
        "check": false
    },
    {
        "id": "46f7c6ba-b4ca-4843-b5d1-76399d1ac52a",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "S",
        "skuCode": "10",
        "skuName": "美年达1",
        "price": 10,
        "isShelf": "上架",
        "check": false
    }
]

目前是id是每一条数据的唯一,如何利用id去重
想要去重后的格式:

[
    {
        "id": "46f7c6ba-b4ca-4843-b5d1-76399d1ac52a",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "S",
        "skuCode": "10",
        "skuName": "美年达1",
        "price": 10,
        "isShelf": "上架",
        "check": true
    },
    {
        "id": "2ea2a723-1a6c-4545-92ce-2ef07547642f",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "M",
        "skuCode": "11",
        "skuName": "可乐1",
        "price": 11,
        "isShelf": "上架",
        "check": true
    },
    {
        "id": "57bc93ad-84de-4737-8ca6-d6abe97eb9ae",
        "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
        "attributeName1": "颜色",
        "attributeValue1": "黄色",
        "attributeName2": "尺寸1",
        "attributeValue2": "L",
        "skuCode": "12",
        "skuName": "雪碧1",
        "price": 12,
        "isShelf": "上架",
        "check": true
    }
]


let obj={};
let newArray=[];
arr.forEach(item=>{
 
  if(!obj[item.id]){
     obj[item.id]=true;
     newArray.push(item)
}
})
console.log(newArray)

这个可以直接采纳了

var obj = {};
arr = arr.reduce(function (item, next) {
obj[next.id] ? '' : obj[next.id] = true && item.push(next);
return item;
}, []);

感谢


temp=[];
result = arr.filter(v=>{if(temp.indexOf(v.id)===-1){temp.push(v.id); return v;}});
console.log(result);
/* 输出结果如下
[
  {
    "id": "46f7c6ba-b4ca-4843-b5d1-76399d1ac52a",
    "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
    "attributeName1": "颜色",
    "attributeValue1": "黄色",
    "attributeName2": "尺寸1",
    "attributeValue2": "S",
    "skuCode": "10",
    "skuName": "美年达1",
    "price": 10,
    "isShelf": "上架",
    "check": false
  },
  {
    "id": "2ea2a723-1a6c-4545-92ce-2ef07547642f",
    "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
    "attributeName1": "颜色",
    "attributeValue1": "黄色",
    "attributeName2": "尺寸1",
    "attributeValue2": "M",
    "skuCode": "11",
    "skuName": "可乐1",
    "price": 11,
    "isShelf": "上架",
    "check": false
  },
  {
    "id": "57bc93ad-84de-4737-8ca6-d6abe97eb9ae",
    "parentId": "a80ff169-d6f6-4752-b980-fd818240410f",
    "attributeName1": "颜色",
    "attributeValue1": "黄色",
    "attributeName2": "尺寸1",
    "attributeValue2": "L",
    "skuCode": "12",
    "skuName": "雪碧1",
    "price": 12,
    "isShelf": "上架",
    "check": false
  }
]
*/

更多关于去重,判定什么的。可以参考这个。