-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
63 lines (58 loc) · 2.02 KB
/
Copy pathindex.html
File metadata and controls
63 lines (58 loc) · 2.02 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>03 Loop|JavaScript Development Lab</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<main class="container">
<header class="hero">
<p class="eyebrow">JavaScript Development Lab · 03</p>
<h1>循环与数据遍历</h1>
<p class="lead">通过一组产品数据,观察 <code>for</code>、<code>while</code> 和 <code>for...of</code> 如何重复执行代码,并把数据逐条输出到页面。</p>
</header>
<section class="panel">
<div class="section-head">
<div>
<span class="step">实验 A</span>
<h2>for 循环</h2>
</div>
<code>for (let i = 0; i < products.length; i++)</code>
</div>
<div id="for-list" class="product-grid"></div>
</section>
<section class="panel">
<div class="section-head">
<div>
<span class="step">实验 B</span>
<h2>for...of 遍历</h2>
</div>
<code>for (const product of products)</code>
</div>
<ul id="for-of-list" class="simple-list"></ul>
</section>
<section class="panel">
<div class="section-head">
<div>
<span class="step">实验 C</span>
<h2>while 循环</h2>
</div>
<code>while (count < 5)</code>
</div>
<div id="while-result" class="number-row"></div>
</section>
<section class="panel note">
<h2>本章观察重点</h2>
<ol>
<li>循环为什么需要“开始条件、继续条件、变化条件”。</li>
<li>数组的 <code>length</code> 为什么经常和循环一起出现。</li>
<li><code>for</code> 适合需要索引时;<code>for...of</code> 适合直接读取每一项。</li>
<li><code>while</code> 如果条件一直成立,会形成死循环。</li>
</ol>
</section>
</main>
<script src="js/app.js"></script>
</body>
</html>