-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path25(数组的遍历).html
39 lines (36 loc) · 1.81 KB
/
25(数组的遍历).html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>这是鱼爸爸的</title>
<script type="text/javascript">
var zhiye = ["老师","清洁工","军人","前端工程师","保姆","画家","诗人","java程序员"];
// document.write(zhiye[0]+"很棒的<br />",zhiye[1]+"很棒的<br />",zhiye[2]+"很棒的<br />",zhiye[3]+"很棒的<br />",zhiye[4]+"很棒的<br />",zhiye[5]+"很棒的<br />",zhiye[6]+"很棒的<br />");
// 遍历数组for
// for (a=0;a<7;a++) {
// var jieguo = zhiye[a];
// document.write(jieguo+"很棒的<br />")
// }
for (a=0;a<zhiye.length;a++) {//从0开始,小于长度length
var jieguo = zhiye[a];
document.write(jieguo+"很棒的<br />")
}
// 用for循环遍历三维数组(依次输出每一部电影,每部电影后面都加上“真好看”三个字)
// var dianying = [[["爱情保卫战","三十三天"],["黑豹","机械人","哆啦A梦"]],[["海蜇王","魔法少女"],["七仙女","天外飞仙","迪迦奥特曼"]],[["红海行动","战狼2"],["捉妖记","二十二日","地理战争"]],[["核弹危机","全球气候"],["孤单一本子","荒野求生","爱你两三天"]],[["唐人街","类型"],["喜剧","爱情","动作"]],[["恐怖","科幻"],["剧情","犯罪","记忆大师"]]];
//
////
// for (a=0;a<6;a++) { //输出a数组document.write(dianying[a]+"真好看","<br />");
//// document.write(dianying[a]+"真好看","<br />");
// for (b=0;b<dianying[a].length;b++) {//输出a,b数组 document.write(dianying[a][b]+"真好看"
//// document.write(dianying[a][b]+"真好看","<br />")
// for (c=0;c<dianying[a].length;c++) {
// document.write(dianying[a][b][c]+"真好看","<br />");
// }
// }
// }
//document.write(dianying.length);
</script>
</head>
<body>
</body>
</html>