Answers for "compare 2 arrays of objects by name js"

5

javascript compare two arrays of objects get same elements

var result = result1.filter(function (o1) {
    return result2.some(function (o2) {
        return o1.id === o2.id; // return the ones with equal id
   });
});
// if you want to be more clever...
let result = result1.filter(o1 => result2.some(o2 => o1.id === o2.id));
Posted by: Guest on August-03-2020

Code answers related to "compare 2 arrays of objects by name js"

Code answers related to "Javascript"

Browse Popular Code Answers by Language