JSON calculates the difference level according to the field

let A = [{id:1,num:2},{id:5,num:12},{id:10,num:4132},{id:55,num:42}]
let B = [1,10]

problem description: filter the corresponding value of the id field in An according to each element in the B array, and delete if the same. Expect the following:

  [{id:5,num:12},{id:55,num:42}]
Es6
Apr.25,2021

how about this?

A.filter((obj)=>{
    return B.indexOf(obj.id)<=-1;
})

let A = [{id: 1, num: 2}, {id: 5, num: 12}, {id: 10, num: 4132}, {id: 55, num: 42}]
let B = [1, 10]

let C = A.filter(({id}) => B.indexOf(id) === -1);

console.log(C)
Menu