javascript - There are differences in the formats of the two arrays, and the problem of comparison and deduplication
某草草
某草草 2017-05-19 10:30:29
0
1
513
arr1 =[{"id":1,"a":2},{"id":2,"c":3},{"id":3,"d":3},{"id":4,"d":3}]; arr2 =[{"id":3,"ed":1111,"vvv":121},{"id":4,"fa":2222},{"id":5,"sa":2222}];

The array formats of arr1 and arr2 are different, but id3 and id4 in arr2 are the same as arr1.
How to realize that after comparing the two arrays, it is found that the IDs are duplicated, and delete the id 3 and id4 in arr1 The entire object?

某草草
某草草

reply all (1)
巴扎黑
var result = arr1.filter(function(element1) { return !arr2.find(function(element2) { return element2.id == element1.id; }); }); console.log(result);
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!