美文网首页
js数组中对象字段判断重复

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

作者: 陪你一场 | 来源:发表于2021-09-03 14:09 被阅读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("重名了!!");
         }
       }
     }
    

    相关文章

      网友评论

          本文标题:js数组中对象字段判断重复

          本文链接:https://www.haomeiwen.com/subject/difqbctx.html