SOURCE

let goods = [
    {_id:1},
    {_id:2},
    {_id:3},
    {_id:4},
]

let settings = [
    {goodIds:[1,3,4,5]},
    {goodIds:[2]}
]

for( let item of settings){

   
      let list =  item.goodIds.filter((g,i) => {
        //   console.log(goods.findIndex(j=>j._id === g))
          if(goods.findIndex(j=>j._id === g) >= 0){
              return item
          }
         
      })
      item.goodIds = list
     

}

console.log(settings)
console 命令行工具 X clear

                    
>
console