-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
89 lines (83 loc) · 3.08 KB
/
Copy pathindex.html
File metadata and controls
89 lines (83 loc) · 3.08 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>05 Array|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 · 05</p>
<h1>数组:管理一组有顺序的数据</h1>
<p class="lead">通过一个最小产品集合,观察 JavaScript 如何创建数组、通过索引读取和修改数据,以及使用 <code>push()</code>、<code>pop()</code>、<code>shift()</code>、<code>unshift()</code> 改变数组。</p>
</header>
<section class="panel">
<div class="section-head">
<div>
<span class="step">实验 A</span>
<h2>创建数组与读取元素</h2>
</div>
<code>products[0]</code>
</div>
<div class="result-grid">
<div class="result-item"><span>第 1 个产品</span><strong id="first-product">-</strong></div>
<div class="result-item"><span>第 2 个产品</span><strong id="second-product">-</strong></div>
<div class="result-item primary"><span>数组长度</span><strong id="product-count">-</strong></div>
</div>
</section>
<section class="panel">
<div class="section-head">
<div>
<span class="step">实验 B</span>
<h2>修改指定位置的数据</h2>
</div>
<code>products[1] = 'Cladding'</code>
</div>
<div class="compare-grid">
<div class="compare-item">
<span>修改前</span>
<strong id="before-update">-</strong>
</div>
<div class="arrow">→</div>
<div class="compare-item primary">
<span>修改后</span>
<strong id="after-update">-</strong>
</div>
</div>
</section>
<section class="panel">
<div class="section-head">
<div>
<span class="step">实验 C</span>
<h2>向数组两端添加和删除数据</h2>
</div>
<code>push / pop / unshift / shift</code>
</div>
<div class="action-list" id="array-actions"></div>
</section>
<section class="panel">
<div class="section-head">
<div>
<span class="step">实验 D</span>
<h2>查看最终数组</h2>
</div>
<code>products</code>
</div>
<div class="product-list" id="product-list"></div>
</section>
<section class="panel note">
<h2>本章观察重点</h2>
<ol>
<li>数组适合保存一组有顺序的数据。</li>
<li>数组索引从 <code>0</code> 开始,而不是从 <code>1</code> 开始。</li>
<li><code>length</code> 表示数组当前包含多少个元素。</li>
<li>通过索引可以读取或修改指定位置的数据。</li>
<li><code>push()</code> / <code>pop()</code> 操作数组尾部,<code>unshift()</code> / <code>shift()</code> 操作数组头部。</li>
</ol>
</section>
</main>
<script src="js/app.js"></script>
</body>
</html>