JSFiddle - React, Tailwind, and code Playground

by alexche8

JavaScript

array1 = [{id: 1}, {id:2}];
array2 = [{id:1}, {id: 3}, {id:4}];
a = _.map(array1, function(obj){ return obj['id']});
b = _.map(array2, function(obj){ return obj['id']});
remove_ids = _.intersection(a,b);
all_objects = array1.concat(array2);
for( key in all_objects){
    console.log(all_objects[key]['id']);
    console.log(remove_ids);
    if(all_objects[key]['id'] in remove_ids){        
        delete all_objects[key];
    }
}
console.log(all_objects);