get object values from 2 different array javascript code example
Example 1: javascript object to array
const numbers = {
one: 1,
two: 2,
};
console.log(Object.values(numbers));
console.log(Object.entries(numbers));
Example 2: javascript compare object arrays keep only entries not in both
var result = result1.filter(function (o1) {
return result2.some(function (o2) {
return o1.id === o2.id;
});
});
let result = result1.filter(o1 => result2.some(o2 => o1.id === o2.id));
let result = result1.filter(o1 => !result2.some(o2 => o1.id === o2.id));