📄 tutorial4_page8.htm
字号:
<html>
<head>
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb_2312-80">
<meta NAME="GENERATOR" CONTENT="Microsoft FrontPage 3.0">
<title>Webmonkey: javascript: Thau's JavaScript Tutorial: Day 1</title>
<meta NAME="keywords"
CONTENT="javascript, hotwired, webmonkey, javascript, javascript tutorial, thau, dave thau, developer resource, developer, development, web
development, design, code, geek, warez, free, new, latest, news, tools,
info, tutorials, how-to, builder, web builder, pag">
<meta NAME="description"
CONTENT="Thau's JavaScript Tutorial: Day 1: Not only does Thau give the JavaScript skinny, but he'll have you writing your first script by the end of the day.">
<meta NAME="Template" CONTENT="E:\LIZEJUN\OFFICE\html.dot">
</head>
<body TEXT="#000000" LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">
<table CELLSPACING="0" BORDER="0" CELLPADDING="3" WIDTH="623">
<tr>
<td WIDTH="58%" VALIGN="MIDDLE"><font FACE="宋体" LANG="ZH-CN" SIZE="4" COLOR="#ff0000"><!--Figure out which page title to display --></font><font
FACE="System,黑体" LANG="ZH-CN" SIZE="4" COLOR="#ff0000"><b>第8页:数组</b></font><font
FACE="System,黑体" LANG="ZH-CN"><br>
<br>
<!-- BYLINE --> </font><font FACE="System,黑体" LANG="ZH-CN" SIZE="2">作者:</font><a
HREF="mailto:thau@wired.com"><font FACE="宋体" LANG="ZH-CN" SIZE="2">Thau!</font></a><font
FACE="宋体" LANG="ZH-CN"> <!-- SEE ALSO LINKS --></font></td>
</tr>
<tr>
<td WIDTH="58%" VALIGN="TOP" BGCOLOR="#ffffff"><font FACE="System,黑体" LANG="ZH-CN"><p
ALIGN="JUSTIFY">我们已了解变量可是数字、字符串及对象参数。还<br>
有一个</font><big><font FACE="宋体" LANG="ZH-CN">Javascript</font><font
FACE="System,黑体" LANG="ZH-CN">的重要部分:数组。</big></p>
<p>数组是一种列表。各种列表比如名单、</font><font FACE="宋体"
LANG="ZH-CN">URL</font><font FACE="System,黑体" LANG="ZH-CN">以颜色列<br>
表都可以存储在数组中。</font> </p>
<font FACE="System,黑体" LANG="ZH-CN"><p>这里我们生成颜色的数组:</p>
<pre>
</font>var colors = new Array("red","blue","green");
</pre>
<font FACE="System,黑体" LANG="ZH-CN"><p>现在你就有了一个数组,你能对它做什么呢?数组<br>
的优点在于数组中的各个元素可以通过数字调用。<br>
第一个元素的数字是</font><font FACE="宋体" LANG="ZH-CN">0</font><font
FACE="System,黑体" LANG="ZH-CN">,可以用以下方式调用:</font> </p>
<font FACE="System,黑体" LANG="ZH-CN"><pre>
</font>var the_element = colors[0];
</pre>
<font FACE="System,黑体" LANG="ZH-CN"><p>执行这一行</font><font FACE="宋体"
LANG="ZH-CN">JavaScript</font><font FACE="System,黑体" LANG="ZH-CN">指令时,变量</font><tt>the_element</tt><font
FACE="宋体" LANG="ZH-CN"> <br>
</font><font FACE="System,黑体" LANG="ZH-CN">所被赋予的值是字符串</font><font
FACE="宋体" LANG="ZH-CN">"red" </font><font FACE="System,黑体" LANG="ZH-CN">。通过写出数组的名称<br>
并将数组中元素的顺序号放在方括号内就可调用数<br>
组中的该元素。数组中第</font><font FACE="宋体" LANG="ZH-CN">2</font><font
FACE="System,黑体" LANG="ZH-CN">个元素的顺序号是</font><font FACE="宋体"
LANG="ZH-CN">1</font><font FACE="System,黑体" LANG="ZH-CN">。</font> </p>
<font FACE="System,黑体" LANG="ZH-CN"><p>一旦生成数组后,你可以添加和修改数组值。如果<br>
你打算将颜色数组的第</font><font FACE="宋体" LANG="ZH-CN">1</font><font
FACE="System,黑体" LANG="ZH-CN">个元素有红色该为紫色,你<br>
可以这样做:<br>
<br>
</font><font FACE="宋体" LANG="ZH-CN">colors[0] = "purple";<br>
</p>
</font><font FACE="System,黑体" LANG="ZH-CN"><p>数组经常用于循环。下文将讲数组和循环的应用。</font>
</p>
<p><!-- PAGE X LINKS --><!-- this stuff checks if there are more pages in this story. if so, we'll
suck out the titles of those pages and build links. Right now, the maximum is
15 pages. --><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">1</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4.htm"><font FACE="System,黑体" LANG="ZH-CN">第四课介绍</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- PAGE X LINKS --><!-- this stuff checks if there are more pages in this story. if so, we'll
suck out the titles of those pages and build links. Right now, the maximum is 15 pages. --><!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">2</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page2.htm"><font FACE="System,黑体" LANG="ZH-CN">循环介绍</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">3</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page3.htm"><font FACE="System,黑体" LANG="ZH-CN">循环的密码</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">4</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page4.htm"><font FACE="System,黑体" LANG="ZH-CN">再谈</font><font
FACE="宋体" LANG="ZH-CN">WHILE</font><font FACE="System,黑体" LANG="ZH-CN">循环</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">5</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page5.htm"><font FACE="宋体" LANG="ZH-CN">For </font><font
FACE="System,黑体" LANG="ZH-CN">循环</font></a><font FACE="System,黑体" LANG="ZH-CN"
SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">6</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page6.htm"><font FACE="System,黑体" LANG="ZH-CN">嵌套循环</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">7</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page7.htm"><font FACE="System,黑体" LANG="ZH-CN">循环练习</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">8</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page8.htm"><font FACE="System,黑体" LANG="ZH-CN">数组</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">9</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page9.htm"><font FACE="System,黑体" LANG="ZH-CN">数组和循环</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">10</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">:</font><a
HREF="tutorial4_page10.html"><font FACE="System,黑体" LANG="ZH-CN">文件目标模块中的数组</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">11</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page11.htm"><font FACE="System,黑体" LANG="ZH-CN">函数</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">12</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page12.html"><font FACE="System,黑体" LANG="ZH-CN">无参数函数</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">13</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page13.htm"><font FACE="System,黑体" LANG="ZH-CN">参数及返回值</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="System,黑体" LANG="ZH-CN">第</font><font FACE="宋体" LANG="ZH-CN">14</font><font
FACE="System,黑体" LANG="ZH-CN">页</font><font FACE="宋体" LANG="ZH-CN" SIZE="2">: </font><a
HREF="tutorial4_page14.htm"><font FACE="System,黑体" LANG="ZH-CN">多于一个参数的函数</font></a><font
FACE="System,黑体" LANG="ZH-CN" SIZE="2"><br>
<!-- this is a mini-template that formats each pageX link. So, if a story
has 15 pages, we need to generate 15 links to it. This is how each one
will look... --> </font><font FACE="宋体" LANG="ZH-CN" SIZE="2"></p>
<p><br>
<!-- AUTHOR TAGLINE --> </font></td>
</tr>
</table>
<font FACE="System,黑体" LANG="ZH-CN">
<p> </p>
</font>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -