Deduplication of js array object

let array1 = [{id:"1"},{id:"2"},{id:"3"}]
let array2 = {id:"1"}

delete array2 if there is array2 in array1, and add it if it doesn"t exist. How to judge the
array object?

what I am writing now:
`

  let array1 = [{id:"1"},{id:"2"},{id:"3"}]
  if(array1.length){
    for(let i=0; i<=array1 .length; iPP){  
      if(array1 [i].id == array2 .id){
        array1.splice(i,1)
      }else{
        array1.push(file)
      }
    }
  }else{
    array1.push(file)
  }`
  
  

let array1 = [{id: '1'}, {id: '2'}, {id: '3'}];
let array2 = {id: '1'};
array1 = array1.filter(({id}) => id !== array2.id);
console.log(array1)

write

if array2 is an array.
let array1 = [{id: '1'}, {id: '2'}, {id: '3'}];
let array2 = [{id: '1'}];
array1 = array1.filter(({id}) => !array2.some(item => item.id === id));
console.log(array1)

let array1 = [{id:'1'},{id:'2'},{id:'3'}]
let array2 = {id:'2'}

let index = -1;
if((index = array1.findIndex(v=>v.id==array2.id))>-1){
  array1.splice(index,1)
}else{
  array1.push(array2);
}
console.log(array1)

var array1 = [{ id: '1' }, { id: '2' }, { id: '3' }];
var array2 = [{ id: '1' }];
function filter (...args) {
  var map = {}
  args.forEach(arr=>{
    arr.forEach(v=>{
      map[v.id] = v
    })
  })
  return Object.entries(map).map(v=>v[1])
}
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b36531-2b780.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b36531-2b780.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?