js以数组值寻找对应id的name

let newTargetKeys = [42,43];
this.projectNameList = [{name:name1,id:42},
{name:name2,id:43}
]

let labelArr = []; this.projectNameList.forEach((item) => { newTargetKeys.forEach((item2) => { if (item.id == item2) { labelArr.push(item.name); } }); });

 

posted @ 2022-06-08 12:23  abcByme  阅读(1473)  评论(0编辑  收藏  举报