检查两个对象列表是否具有相同的属性

时间:2018-03-09 18:51:52

标签: javascript jquery loops salesforce-lightning

我有两个对象列表,它们中有不同的字段。我想检查两个字段在javascript中是否没有相同的值。  我的例子是列表一

0:Client_Issue_Reference__c:null
  End__c:"2018-03-06T23:00:00.000Z"
  Id:"a0Q2F000000oRyBUAU"
  Resource_Full_Name__c:"test user"
  Start__c:"2018-03-06T15:00:00.000Z"

我的第二个清单是

0:Id:"0050W000006r0xnQAA"
  IsActive:true
  Name:"test user"

我想看看Resource_Full_Name__c!=姓名 目前我有

for (var i = 0; i < listOne.length; i++) {
  for (var j = 0; j < listTwo.length; j++) {
     if (listOne[i].Name != listTwo[j].Resource_Full_Name__c) {
          buildingObjectAllUser = {}
          sobjectType: "testObject";
          buildingObjectAllUser.Id = listOne[i].Id;
          buildingObjectAllUser.Start__c = "2018-03-06T23:00:00.000Z";
          buildingObjectAllUser.End__c = "2018-03-06T23:00:00.000Z";
          buildingObjectAllUser.Name = "No Hours";
          buildingObjectAllUser.Resource_Full_Name__c = listOne[i].Name;
          listThree.push(buildingObjectAllUser);
        }
      }
    }

这个问题花了很多时间,它真的很慢

1 个答案:

答案 0 :(得分:0)

这应该更快

strace -e write yes | { sleep 0.1; :; }