📌  相关文章
📜  javascript 按 id 过滤对象数组 - Javascript 代码示例

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

代码示例1
const myArray = [{id: 1, name:'pipi'}, {id: 2, name:'popo'}];
const id = 2;

const variableOne = myArray.filter(itemInArray => itemInArray.id === id);
console.log(cariableOne[0].name);