📌  相关文章
📜  定位并删除数组中的对象 - Javascript 代码示例

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

代码示例1
// we have an array of objects, we want to remove one object using only the id property
var apps = [{id:34,name:'My App',another:'thing'},{id:37,name:'My New App',another:'things'}];
 
// get index of object with id:37
var removeIndex = apps.map(function(item) { return item.id; }).indexOf(37);
 
// remove object
apps.splice(removeIndex, 1);