typescript find non matching objects in two arrays code example
Example: typescript find non matching objects in two arrays
const first = ['cat', 'dog', 'mouse'];
const second = ['zebra', 'tiger', 'dog', 'mouse'];
const removeCommon = (first, second) => {
const spreaded = [...first, ...second];
return spreaded.filter(el => {
return !(first.includes(el) && second.includes(el));
})
};
console.log(removeCommon(first, second));