引用场景: 列表带checkbox,可多选删除操作, 求列表剩余的条目
字解:对象a为全集数组, b为已选择数组, 根据b数组筛选出剩余的数组
const a = [
{id:1, name:"name1"},
{id:2, name:"name2"},
{id:3, name:"name3"},
{id:4, name:"name4"}
]
const b = [
{id:1, name:"name1"},
{id:3, name:"name3"},
]
const c = a.filter(item =>{
return b.every(list => {
return item.id !== list.id
});
});