1 function getDistinct(arr1,arr2){
2 var arr=[];
3 for(var i=0;i<arr1.length;i++){
4 var obj1=arr1[i].id
5 var isExist = false;
6 for (var j=0;j<arr2.length;j++){
7 var obj2=arr2[j].id
8 if(obj1==obj2){
9 isExist = true;
10 break;
11 }
12 }
13 if(!isExist){
14 arr.push(obj1)
15 }
16 }
17 return arr;
18 }
19 var arr1=[
20 {
21 'id':1
22 },
23 {
24 'id':2
25 },
26 {
27 'id':3
28 }
29 ]
30 var arr2=[
31 {
32 'id':1
33 },
34 {
35 'id':2
36 }
37 ]
38 var arr3=getDistinct(arr1,arr2);
39 console.log(arr3,'arr3') //[3]