js数组中对象字段判断重复
2021-09-03 本文已影响0人
陪你一场
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("重名了!!");
}
}
}