js数组中对象字段判断重复

var arr =[
    {
        "platform_id": 1,
        "type_id": 1,
        "account_name": "asd",
        "account_id": "asd"
    },
    {
        "platform_id": 1,
        "type_id": 8,
        "account_name": "asd",
        "account_id": "as"
    },
    {
        "platform_id": 15,
        "type_id": 1,
        "account_name": "asd",
        "account_id": "asd"
    },
    {
        "platform_id": 15,
        "type_id": 8,
        "account_name": "asd",
        "account_id": "asd"
    }
]
for (var i = 0; i < arr.length - 1; i++) {
  for (var j = i + 1; j < arr.length; j++) {
     if (arr[i].platform_id === arr[j].platform_id && arr[i].account_id === arr[j].account_id) {
       console.log("重名了!!");
     }
   }
 }

你可能感兴趣的:(js数组中对象字段判断重复)