How to exclude objects from the array if they exist in another array?

Repl Link

Here for example how to create a new array result in which objects of obj1 with ID 4 and 5.
That is, the objects with ID 1, 2, 3( which are written in the array arr1) will not be in the new sample.
How to do it as professionally as possible ?
March 19th 20 at 08:50
3 answers
March 19th 20 at 08:52
Solution
const result = obj1.filter(n => !arr1.includes(n.id));
March 19th 20 at 08:54
Two things are needed:
1. Using a for loop (forEach) in the body which, conditional " If " statement
2. Using the method slice()
March 19th 20 at 08:56
var array1 = [1, 2, 3, 4];
var array2 = [1, 3, 4];

var diff = array1.concat(array2).filter(function (e, i, array) {
 return array.indexOf(e) === array.lastIndexOf(e);
});

console.log(diff);
// [2]

Find more questions by tags JavaScript