📌  相关文章
📜  lodash 从数组中删除未定义的值 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:55.182000             🧑  作者: Mango

代码示例2
var a = [
  {id: 1, name: 'A'},
  {id: 2, name: 'B'},
  {id: 3,  name: 'C'},
  {id: 4, name: 'D'}
];
var removeItem = [1,2];
removeItem.forEach(function(id){
   var itemIndex = a.findIndex(i => i.id == id);
   a.splice(itemIndex,1);
});
console.log(a);