Java Script数组循环

java

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title></title>

</head>

<body>

<script type="text/javascript" >

//这里的对象数据是从今日头条源代码粘的

var obj={"has_more": false, "message": "success", "data": [{"single_mode": false, "abstract": "2020\u5e74\u519c\u5386\u6625\u8282\u56e0\u4e3a\u75ab\u60c5\u4e0d\u5c11\u4eba\u8fc7\u7740\u4e0d\u4e00\u6837\u7684\u5e74\u5728\u8fd9\u573a\u6ca1\u6709\u785d\u70df\u7684\u6218\u4e89\u7206\u53d1\u4e4b\u9645\u5728\u4eba\u4eec\u88ab\u4e0d\u65ad\u63d0\u9192\u201c\u5c3d\u91cf\u4e0d\u8981\u53bb\u6b66\u6c49\u201d\u65f6\u6709\u4e00\u4e9b\u4eba\u6bc5\u7136\u51b3\u7136\u5730\u8d76\u5f80\u75ab\u60c5\u7684\u6700\u524d\u7ebf\u25b3\u89c6\u9891\uff1a\u5fae\u89c6\u9891\u4e28\u51fa\u53d1\uff01", "middle_mode": true, "more_mode": false, "tag": "video_domestic", "has_gallery": false, "tag_url": "video", "title": "\u5fae\u89c6\u9891\u4e28\u51fa\u53d1\uff01\u5411\u6b66\u6c49\u96c6\u7ed3", "has_video": true, "chinese_tag": "\u89c6\u9891", "source": "\u592e\u89c6\u7f51\u65b0\u95fb", "group_source": 2, "comments_count": 1, "media_url": "/c/user/token/MS4wLjABAAAAaezOXkHVr0_i2JvWXprb4zLGpRInnKStptFm5WsXHKU/", "media_avatar_url": "//p1.pstatp.com/large/bc20000b91968707dab", "video_duration_str": "02:48", "source_url": "/group/6786214506084172291/", "article_genre": "video", "is_stick": true, "item_id": "6786214506084172291", "is_feed_ad": false, "video_id": "v02004070000bomnjai7u0rdan0epc5g", "behot_time": 1580039680, "image_url": "//p1.pstatp.com/list/pgc-image/33a4b44195c14ccd94aebc8df595344c", "video_play_count": 6127, "group_id": "6786214506084172291", "middle_image": "http://p1.pstatp.com/list/pgc-image/33a4b44195c14ccd94aebc8df595344c"}, {"single_mode": false, "abstract": "\u5927\u5e74\u521d\u4e00\uff0c\u4e60\u8fd1\u5e73\u5bf9\u75ab\u60c5\u9632\u63a7\u4f5c\u51fa\u8d85\u5f3a\u90e8\u7f72", "middle_mode": true, "more_mode": false, "tag": "news_media", "comments_count": 523, "tag_url": "search/?keyword=%E4%BC%A0%E5%AA%92", "title": "\u5927\u5e74\u521d\u4e00\uff0c\u4e60\u8fd1\u5e73\u5bf9\u75ab\u60c5\u9632\u63a7\u4f5c\u51fa\u8d85\u5f3a\u90e8\u7f72", "chinese_tag": "\u4f20\u5a92", "source": "\u65b0\u534e\u7f51\u5ba2\u6237\u7aef", "group_source": 2, "image_url": "//p9.pstatp.com/list/pgc-image/Robd1TaC9ZVlid", "media_url": "/c/user/token/MS4wLjABAAAAP09LrX61xFpIWrgGdBDqkp-5om9Lans_kuIZ_ipAGRE/", "media_avatar_url": "//p9.pstatp.com/large/ff1b0000332acf4a6c2e", "source_url": "/group/6785915935774474765/", "article_genre": "article", "is_stick": true, "item_id": "6785915935774474765", "is_feed_ad": false, "behot_time": 1580039670, "has_gallery": false, "group_id": "6785915935774474765", "middle_image": "http://p9.pstatp.com/list/pgc-image/Robd1TaC9ZVlid"}, {"single_mode": true, "abstract": "\u5317\u4eac\u5e02\u65b0\u578b\u51a0\u72b6\u75c5\u6bd2\u611f\u67d3\u7684\u80ba\u708e\u75ab\u60c5\u9632\u63a7\u5de5\u4f5c\u65b0\u95fb\u53d1\u5e03\u4f1a\u4e0a\uff0c\u5317\u4eac\u5e02\u4ea4\u901a\u59d4\u65b0\u95fb\u53d1\u8a00\u4eba\u5bb9\u519b\u8868\u793a\uff0c\u201c\u5bf9\u5916\u4ea4\u901a\u57fa\u672c\u6b63\u5e38\uff0c\u6ca1\u6709\u5c01\u57ce\uff0c\u4e5f\u4e0d\u4f1a\u5c01\u57ce\u3002\u201d", "middle_mode": true, "more_mode": false, "tag": "news_society", "comments_count": 164, "tag_url": "news_society", "title": "\u5317\u4eac\u5e02\u4ea4\u901a\u59d4\uff1a\u6ca1\u6709\u5c01\u57ce\uff0c\u4e5f\u4e0d\u4f1a\u5c01\u57ce", "chinese_tag": "\u793e\u4f1a", "source": "\u5317\u4eac\u65e5\u62a5\u5ba2\u6237\u7aef", "group_source": 2, "has_gallery": false, "media_url": "/c/user/token/MS4wLjABAAAAaUhxLC10yf766zvPm3RSYweRiaom2ui_ZccXzB1r4vo/", "media_avatar_url": "//p3.pstatp.com/large/66bd0002f4ac966aa1d9", "source_url": "/group/6786175891832570376/", "article_genre": "article", "item_id": "6786175891832570376", "is_feed_ad": false, "behot_time": 1580039660, "image_url": "//p9.pstatp.com/list/190x124/pgc-image/59d68198ba6f40a0b0561513ea4f1aed", "group_id": "6786175891832570376", "middle_image": "http://p9.pstatp.com/list/pgc-image/59d68198ba6f40a0b0561513ea4f1aed"}, {"single_mode": true, "abstract": "\u76ee\u524d\u53ef\u4ee5\u786e\u5b9a\u7684\u662f\uff0c\u65b0\u578b\u51a0\u72b6\u75c5\u6bd2\u540c\u6837\u6765\u81ea\u8759\u8760\uff0c\u800c\u4e2d\u95f4\u5bbf\u4e3b\u4f9d\u7136\u6ca1\u6709\u5b9a\u8bba\uff0c\u6709\u5b66\u8005\u8ba4\u4e3a\u662f\u86c7\uff0c\u4e5f\u6709\u5b66\u8005\u8ba4\u4e3a\u662f\u6c34\u8c82\u3002", "middle_mode": true, "more_mode": true, "tag": "news_health", "comments_count": 38, "tag_url": "news_health", "title": "\u6851\u62ff\u623f\u7684\u9ad8\u6e29\u80fd\u5426\u6d88\u706d\u4e0d\u8010\u9ad8\u6e29\u7684\u65b0\u578b\u51a0\u72b6\u75c5\u6bd2\uff1f", "chinese_tag": "\u5065\u5eb7", "source": "\u529b\u5b66Nerd\u738b\u5c0f\u80d6", "group_source": 2, "has_gallery": false, "media_url": "/c/user/token/MS4wLjABAAAAAAE6heYPtq2cWRDotAZ_UUPbwFF8Rhuz3Ehe0-FPFIg/", "media_avatar_url": "//p1.pstatp.com/large/616b0005cf0efac2ab0a", "image_list": [{"url": "//p9.pstatp.com/list/dfic-imagehandler/706daad4-ff18-4701-9962-255525463f01"}, {"url": "//p1.pstatp.com/list/dfic-imagehandler/f0ae8ca6-7aab-486f-8546-20103051151a"}, {"url": "//p1.pstatp.com/list/dfic-imagehandler/b66de247-1771-482c-8c74-d22e38352957"}], "source_url": "/group/6786127472489398795/", "article_genre": "article", "item_id": "6786127472489398795", "is_feed_ad": false, "behot_time": 1580039650, "image_url": "//p9.pstatp.com/list/dfic-imagehandler/706daad4-ff18-4701-9962-255525463f01", "group_id": "6786127472489398795", "middle_image": "http://p9.pstatp.com/list/dfic-imagehandler/706daad4-ff18-4701-9962-255525463f01"}, {"chinese_tag": "\u79d1\u5b66", "media_avatar_url": "//p3.pstatp.com/large/d2a0015e51ed3a11c15", "is_feed_ad": false, "tag_url": "search/?keyword=%E7%A7%91%E5%AD%A6", "title": "\u6838\u5fc3\u671f\u520a\u767b\u201c\u62cd\u9a6c\u5c41\u8bba\u6587\u201d\u4e2d\u79d1\u9662\uff1a\u505c\u520a\u6574\u987f", "single_mode": true, "middle_mode": true, "abstract": "\u8fd1\u65e5\uff0c\u6838\u5fc3\u671f\u520a\u300a\u51b0\u5ddd\u51bb\u571f\u300b\u4e00\u7bc7\u751f\u6001\u7ecf\u6d4e\u5b66\u8bba\u6587\u5927\u8c08\u5bfc\u5e08\u548c\u5e08\u5a18\uff0c\u9610\u8ff0\u201c\u5bfc\u5e08\u5d07\u9ad8\u611f\u548c\u5e08\u5a18\u4f18\u7f8e\u611f\u201d\uff0c\u8be5\u4e8b\u4ef6\u5f15\u70ed\u8bae\u3002", "tag": "science_all", "behot_time": 1580039640, "source_url": "/group/6786212100214620685/", "source": "\u89c2\u5bdf\u8005\u7f51", "more_mode": false, "article_genre": "article", "image_url": "//p1.pstatp.com/list/190x124/pgc-image/RnLCFKjJImbkpo", "group_source": 2, "item_id": "6786212100214620685", "has_gallery": false, "group_id": "6786212100214620685", "middle_image": "http://p1.pstatp.com/list/pgc-image/RnLCFKjJImbkpo", "media_url": "/c/user/token/MS4wLjABAAAAjMIvjM9ZCTBrb2fOwv_KpFPQ6MJh6iHm2OlIm9xgyJk/"}, {"single_mode": true, "abstract": "\u622a\u81f3\u4eca\u65e520\u65f6\uff0c\u9488\u5bf9\u65b0\u578b\u51a0\u72b6\u75c5\u6bd2\u80ba\u708e\u75ab\u60c5\uff0c\u76ee\u524d\u5168\u56fd\u5171\u6709\u5e7f\u4e1c\u3001\u6e56\u5357\u3001\u6d59\u6c5f\u3001\u5317\u4eac\u3001\u4e0a\u6d77\u3001\u5929\u6d25\u3001\u6e56\u5317\u3001\u5c71\u4e1c\u7b4930\u4e2a\u7701\u3001\u5e02\u3001\u81ea\u6cbb\u533a\u542f\u52a8\u91cd\u5927\u7a81\u53d1\u516c\u5171\u536b\u751f\u4e8b\u4ef6\u4e00\u7ea7\u54cd\u5e94\u3002", "middle_mode": true, "more_mode": true, "tag": "news_politics_general", "comments_count": 1005, "tag_url": "search/?keyword=None", "title": "\u591a\u5730\u5b9e\u884c\u4ea4\u901a\u7ba1\u5236\u53d6\u6d88\u5a31\u4e50\u6d3b\u52a8\uff0c\u6e56\u5317\u90e8\u5206\u6751\u5b50\u5806\u571f\u77f3\u5c01\u8def", "source": "\u65b0\u4eac\u62a5", "group_source": 2, "has_gallery": false, "media_url": "/c/user/token/MS4wLjABAAAAzHj3Nx8o7swEMOeE61Y8tzeXORNWzcXvBa7NNxQhSFg/", "media_avatar_url": "//p1.pstatp.com/large/8532/7581013616", "image_list": [{"url": "//p3.pstatp.com/list/pgc-image/RobMBLgCXpVb33"}, {"url": "//p1.pstatp.com/list/pgc-image/RobMBMKE2N9sBk"}, {"url": "//p1.pstatp.com/list/pgc-image/RobMBMe1T2FtQL"}], "source_url": "/group/6785898076486763022/", "article_genre": "article", "item_id": "6785898076486763022", "is_feed_ad": false, "behot_time": 1580039630, "image_url": "//p3.pstatp.com/list/190x124/pgc-image/RobMBLgCXpVb33", "group_id": "6785898076486763022", "middle_image": "http://p3.pstatp.com/list/pgc-image/RobMBLgCXpVb33"}, {"single_mode": true, "abstract": "\u5728\u6d77\u6e7e\u6218\u4e89\u4e2d\uff0c\u7f8e\u7b2c82\u7a7a\u964d\u5e08\u7684\u5927\u91cf\u4f1e\u5175\uff0c\u572848\u5c0f\u65f6\u5185\u4ece\u7f8e\u56fd\u51fa\u53d1\uff0c\u8fdc\u7a0b\u5954\u88ad\uff0c\u9996\u5148\u8fdb\u5165\u6c99\u7279\uff0c\u7b2c101\u7a7a\u4e2d\u7a81\u51fb\u5e08\u4e5f\u968f\u540e\u5230\u8fbe\uff0c\u8fd9\u963b\u6b62\u4e86\u4f0a\u62c9\u514b\u8d38\u7136\u53d1\u52a8\u88ad\u51fb\uff0c\u5bf9\u540e\u6765\u519b\u4e8b\u884c\u52a8\u7684\u5c55\u5f00\u8d77\u5230\u4e86\u4e3e\u8db3\u8f7b\u91cd\u7684\u4f5c\u7528\u3002", "middle_mode": true, "more_mode": true, "tag": "news_military", "comments_count": 976, "tag_url": "news_military", "title": "\u89e3\u653e\u519b\u8d76\u8d74\u6b66\u6c49\uff0c\u5750\u7684\u662f\"\u95f7\u7f50\u8f66\"\uff1f\u771f\u76f8\u662f\uff0c\u4ed6\u4eec\u642d\u4e58\u4e86\u6700\u5f3a\u4e13\u673a", "chinese_tag": "\u519b\u4e8b", "source": "\u5175\u5668", "group_source": 2, "has_gallery": false, "media_url": "/c/user/token/MS4wLjABAAAAa7YpL5eFAr20PignGfkQoKujx2qewbtC_2s69TBlQrc/", "media_avatar_url": "//p3.pstatp.com/large/412001c321025130b5a", "image_list": [{"url": "//p1.pstatp.com/list/pgc-image/5540d61c391046caa92a9bfc341b1174"}, {"url": "//p1.pstatp.com/list/pgc-image/7f4e9be4975542f6a2d8cdfde38980b9"}, {"url": "//p1.pstatp.com/list/pgc-image/340744da984b46d680396b33667ba5fd"}], "source_url": "/group/6786032122445431300/", "article_genre": "article", "item_id": "6786032122445431300", "is_feed_ad": false, "behot_time": 1580039620, "image_url": "//p1.pstatp.com/list/190x124/pgc-image/5540d61c391046caa92a9bfc341b1174", "group_id": "6786032122445431300", "middle_image": "http://p1.pstatp.com/list/pgc-image/5540d61c391046caa92a9bfc341b1174"}, {"single_mode": true, "abstract": "\u73b0\u5728\u5168\u56fd\u9664\u4e86\u897f\u85cf\u4ee5\u5916\uff0c\u6240\u6709\u7684\u7701\u5e02\u90fd\u6709\u786e\u8bca\u6216\u8005\u7591\u4f3c\u75c5\u4f8b\uff0c\u800c\u6838\u5fc3\u5730\u5e26\u6b66\u6c49\uff0c\u4e43\u81f3\u6e56\u5317\u75c5\u4f8b\u66f4\u662f\u975e\u5e38\u4e4b\u591a\uff0c\u5e94\u8be5\u8bf4\u662f\u4e00\u4e2a\u5f71\u54cd\u5168\u56fd\u4e43\u81f3\u5bf9\u4e16\u754c\u4e0a\u5f88\u591a\u56fd\u5bb6\u90fd\u9020\u6210\u4e86\u4e00\u4e9b\u5f71\u54cd\u7684\u75ab\u60c5\u3002", "middle_mode": true, "more_mode": true, "tag": "news_health", "comments_count": 8, "tag_url": "news_health", "title": "\u5173\u4e8e\u65b0\u578b\u51a0\u72b6\u75c5\u6bd2\u75ab\u60c5\uff0c\u4e0d\u8981\u6050\u614c\uff0c\u8ba9\u6211\u4eec\u4e00\u8d77\u71ac\u8fc7\u4e24\u4e2a14\u5929", "chinese_tag": "\u5065\u5eb7", "source": "\u533b\u58f0\u76f8\u4f34\u5d14\u677e\u8bf4", "group_source": 2, "has_gallery": false, "media_url": "/c/user/token/MS4wLjABAAAAv7BaKCY9kJwdNP_gRAtXfGwSMhoZ_PjTqszCS7Srmws/", "media_avatar_url": "//p3.pstatp.com/large/9b2000020a6ce86162bd", "image_list": [{"url": "//p1.pstatp.com/list/pgc-image/8d99db8cf2174479bae159c6be71380f"}, {"url": "//p9.pstatp.com/list/dfic-imagehandler/a85164d8-f295-4dd9-b956-24867b6fc280"}, {"url": "//p1.pstatp.com/list/dfic-imagehandler/438f894e-6e90-4370-8458-f07b06d192ef"}], "source_url": "/group/6786110414116618766/", "article_genre": "article", "item_id": "6786110414116618766", "is_feed_ad": false, "behot_time": 1580039610, "image_url": "//p1.pstatp.com/list/190x124/pgc-image/8d99db8cf2174479bae159c6be71380f", "group_id": "6786110414116618766", "middle_image": "http://p1.pstatp.com/list/pgc-image/8d99db8cf2174479bae159c6be71380f"}, {"single_mode": true, "abstract": "\u8d23\u4efb\u7f16\u8f91\uff1a\u738b\u8d85\u6e90\u81ea\u79d1\u666e\u4e2d\u56fd", "middle_mode": true, "more_mode": true, "tag": "news", "comments_count": 718, "tag_url": "search/?keyword=%E5%85%B6%E5%AE%83", "title": "\u65b0\u578b\u51a0\u72b6\u75c5\u6bd2\u7684\u4f20\u67d3\u6027\u6709\u591a\u5f3a\uff1f\u5982\u4f55\u907f\u514d\u4e2d\u62db\uff1f", "chinese_tag": "\u5176\u5b83", "source": "\u767d\u6c34\u79d1\u666e", "group_source": 2, "has_gallery": false, "media_url": "/c/user/token/MS4wLjABAAAAWcOlDaw8piPcA2zne_opELvupu_ytZ1AuuA8wsuuxdo/", "media_avatar_url": "//p5a.pstatp.com/large/3b08000025665b48e527", "image_list": [{"url": "//p1.pstatp.com/list/pgc-image/73122e443122472fb973cbc405da89f5"}, {"url": "//p3.pstatp.com/list/pgc-image/bb9032d9fd8e4c368aa58b9cee575577"}, {"url": "//p1.pstatp.com/list/pgc-image/1c6076f2a88941bab61b2030e635551c"}], "source_url": "/group/6784977076265943566/", "article_genre": "article", "item_id": "6784977076265943566", "is_feed_ad": false, "behot_time": 1580039600, "image_url": "//p1.pstatp.com/list/190x124/pgc-image/73122e443122472fb973cbc405da89f5", "group_id": "6784977076265943566", "middle_image": "http://p1.pstatp.com/list/pgc-image/73122e443122472fb973cbc405da89f5"}, {"chinese_tag": "\u793e\u4f1a", "media_avatar_url": "//p2.pstatp.com/thumb/1398/4664054183", "is_feed_ad": false, "tag_url": "news_society", "title": "\u4e3a\u6e56\u5317\u6350\u6b3e\u6350\u7269\uff0c\u8bf7\u770b\u8fd9\u91cc", "single_mode": false, "middle_mode": false, "abstract": "\u6b66\u6c49\u5e02\u6148\u5584\u603b\u4f1a\u63a5\u53d7\u6350\u8d60\u6237\u540d\uff1a\u6b66\u6c49\u5e02\u6148\u5584\u603b\u4f1a\uff1b\u94f6\u884c\u8d26\u53f7\uff1a421860158018170139664\uff1b\u5f00\u6237\u884c\uff1a\u4ea4\u901a\u94f6\u884c\u6e56\u5317\u7701\u5206\u884c\u8425\u4e1a\u90e8\uff1b\u8054\u884c\u884c\u53f7\uff1a301521000021\u8054\u7cfb\u7535\u8bdd\uff1a027-85729696\u3001027-85751277\u3001027-85678311\u3001027-85798437\u3001", "tag": "news_society", "behot_time": 1580039590, "source_url": "/group/6786211799101342215/", "source": "\u4e2d\u56fd\u9752\u5e74\u7f51", "more_mode": false, "article_genre": "article", "has_gallery": false, "group_source": 2, "item_id": "6786211799101342215", "group_id": "6786211799101342215", "media_url": "/c/user/token/MS4wLjABAAAAxvhRvfp8QotIo15bD0cWxFiKWMXaUldeG_Ep2unxBqM/"}], "next": {"max_behot_time": 1580039590}}

console.log(obj)

var arr=obj.data

console.log(arr)

//这里的for循环与下面的foreach循环等效

//foreach循环比for循环更方便

// for(var i=0;i<arr.length;i++)

// {

// console.log(arr[i].title)

// document.write(\'<h1><a href="https://www.toutiao.com\'+arr[i].source_url+\'">\'+arr[i].title+\'</a></h1>\')

// }

arr.forEach(function(item,index,arr){

//item是当前循环到的数据

//index是当前循环的索引值

//arr是当前数组

//arr[index]是与item相等的

document.write(\'<h1><a href="https://www.toutiao.com\'+item.source_url+\'">\'+item.title+\'</a></h1>\')

})

</script>

</body>

</html>

 

 

 

以上是 Java Script数组循环 的全部内容, 来源链接: utcz.com/z/390919.html

回到顶部