<input type="text" id="app">
<script>
var arr = [
{name:"李四",id:"1001"},
{name:"王四",id:"1002"},
{name:"张四",id:"1003"},
{name:"赵四",id:"1004"}
]
/*
1.要获取数组中的值
2.根据id值 获取数组中对应项的下标
3.删除对应的项
*/
var app = document.getElementById("app");
app.onkeydown = function(event){
if(event.keyCode==13){
var id =Number(this.value);
var index =arr.findIndex(item=>{
return item.id == id;
})
arr.splice(index,1);
console.log(arr)
}
}
</script>