let data = [
{
id: "1",
name: "test"
},
{
id: "2",
name: "test"
}
];
let data2 = [
{
id: "1",
name: "test"
},
{
id: "3",
name: "test"
}
];
const result = data.filter((a) => data2.some((b) => a.id === b.id));
console.log(result);