Создать новый массив:
const newArr2 = arr2.filter(n => arr1.includes(n.name));
// или
const newArr2 = arr2.filter(function(n) {
return this.has(n.name);
}, new Set(arr1));
// или
const obj2 = Object.fromEntries(arr2.map(n => [ n.name, n ]));
const newArr2 = arr1.reduce((acc, n) => ((n = obj2[n]) && acc.push(n), acc), []);
Удалить элементы существующего:
let numDeleted = 0;
for (let i = 0; i < arr2.length; i++) {
arr2[i - numDeleted] = arr2[i];
numDeleted += !arr1.includes(arr2[i].name);
}
arr2.length -= numDeleted;
// или
for (let i = arr2.length; i--;) {
if (!arr1.includes(arr2[i].name)) {
arr2.splice(i, 1);
}
}
// или
arr2.reduceRight((_, n, i, a) => arr1.includes(n.name) || a.splice(i, 1), null);
// или
arr2.splice(0, arr2.length, ...arr2.filter(n => arr1.includes(n.name)));