I need to delete the object list by using matched key. (example the key have 1 and 2 , the result will only show 3)

let selectedRow = ["1","2","3"]; 

let arr = [ 
   { id:1, name:"eddie" }, 
   { id:2, name:"jake" }, 
   { id:3, name:"susan" }, 
];

Answer

  1. Updation on the answer provided by Andy, If you don’t want to update the exiting array and want to result in a new array

let selectedRow = ["1", "2"];

let arr = [
    { id: 1, name: "eddie" },
    { id: 2, name: "jake" },
    { id: 3, name: "susan" },
];

const result = arr.filter(item => !selectedRow.includes(item.id.toString()))
console.log(result)
  1. If you want changes in a current array and don’t want to store results in a new array (Not the most efficient solution though)

let selectedRow = ["1", "2"];

let arr = [
    { id: 1, name: "eddie" },
    { id: 2, name: "jake" },
    { id: 3, name: "susan" },
];

for (const row of selectedRow) {
    const index = arr.findIndex(item => item.id.toString() === row)
    if (index !== -1)
        arr.splice(index, 1)
}

console.log(arr)