javascript中提取元素

{"topic1":{"609":["A","B"],"610":["C","D","E"]}}



在js中如何把609,610,A,B,C,D,E分别提取出来?


隔江千里
浏览 475回答 1
1回答

函数式编程

var obj = {"topic1":{"609":["A","B"],"610":["C","D","E"]}};for(var p in obj.topic1) {&nbsp; &nbsp; console.log(p);&nbsp; //获取到609、610&nbsp; &nbsp; var t = obj.topic1[p];&nbsp; &nbsp; for(var i = 0; i < t.length; i++){&nbsp; &nbsp; &nbsp; &nbsp; console.log(t[i]);&nbsp; //获取A、B、C、D、E&nbsp; &nbsp; }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript