how to remove one array from another array in javascript code example
Example: remove an element in array useing another array
Remove an item comparing from other array
const toRemoveMap = toRemove.reduce(
function(memo, item) {
memo[item] = memo[item] || true;
return memo;
},
{}
);
const filteredArray = myArray.filter(function (x) {
return toRemoveMap[x];
});
const toRemoveMap = toRemove.reduce((memo, item) => ({
...memo,
[item]: true
}), {});
const filteredArray = myArray.filter(x => toRemoveMap[x.id]);
From <https://stackoverflow.com/questions/19957348/remove-all-elements-contained-in-another-array>