Use filter
and includes
method
const ids = ["1", "2"];
const objs = [
{
id: "1",
name: "one",
},
{
id: "1",
name: "two",
},
{
id: "3",
name: "three",
},
{
id: "4",
name: "four",
},
];
const res = objs.filter(({ id }) => !ids.includes(id));
console.log(res);
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…