为了账号安全,请及时绑定邮箱和手机立即绑定

获取对象数组中符合条件的key值

获取对象数组中符合条件的key值

牛魔王的故事 2019-04-27 17:16:54
不知道怎么写了,求帮助。[{"pid":"0","name":"智慧定位","level":"1","industry_id":"37","scene":[{"pid":"37","name":"公车监管","level":"2","scene_id":"38"}]},{"pid":"0","name":"智慧工地","icon":"","level":"1","industry_id":"39","scene":[{"pid":"39","name":"智能安全帽","icon":"","level":"2","scene_id":"40"},{"pid":"39","name":"智慧工地-综合","icon":"","level":"2","scene_id":"41"}]}]想知道scene_id为41的对象的industry_id
查看完整描述

2 回答

?
RISEBY

TA贡献1856条经验 获得超5个赞

functionfindID(arr){
letid;
arr.forEach(value=>{
for(keyinvalue){
if(key=='scene'){
for(leti=0;iif(value[key][i].scene_id=='41'){
id=value.industry_id;
break;
}
}
}
if(id)
break;
}
});
returnid;
}
console.log(findID(arr));
                            
查看完整回答
反对 回复 2019-04-27
  • 2 回答
  • 0 关注
  • 439 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信