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

萌新求教!获取对象数组中符合条件的key值求指导!

萌新求教!获取对象数组中符合条件的key值求指导!

梦里花落0921 2019-06-09 11:37:52
不知道怎么写了,求帮助。[{"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 回答

?
回首忆惘然

TA贡献1847条经验 获得超11个赞

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-06-09
  • 2 回答
  • 0 关注
  • 243 浏览
慕课专栏
更多

添加回答

举报

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