⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 day4_8.html

📁 JScript 用户指南 JavaScript 语言参考 内容 :JScript 函数 JScript 错误 JScript 方法 JScript 对象 JScript 语句 Scripting 运行
💻 HTML
字号:
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312-80">
<style type="text/css">
<!--
a:link {  color: blue; text-decoration: none}
a:visited {  color: purple; text-decoration: none}
a:hover {  color: #CC0033; text-decoration: underline}
-->
</style>
<title>JavaScript教程</title>
</head>

<body topmargin="1" leftmargin="2">

<table border="0" width="591" cellspacing="0">
  <tr>
    <td bgcolor="#ffff99" width="451">JavaScript教程 - 第四课</td>
  </tr>
  <tr>
    <td bgcolor="#FF6600" width="451"><a href="mailto:thau@wired.com">Thau</a></td>
  </tr>
</table>
<div align="left">

<table border="0" width="630" cellspacing="0">
  <tr>
    <td width="458" valign="top" align="left"><strong><small><small><br>
    </small></small><font face="宋体" size="3">第八页:</font><font SIZE="3">数组</strong> 
    <p ALIGN="JUSTIFY">我们已了解变量可是数字、字符串及对象参数。还有一个<br>
    <font face="宋体">Javascript</font>的重要部分:数组。</p>
    <p>数组是一种列表。各种列表比如名单、<font face="宋体">URL</font>以颜色列表都可以存<br>
    储在数组中。 </p>
    <p>这里我们生成颜色的数组:</p>
    <blockquote>
      <pre>
<font face="宋体">var colors = new Array(&quot;red&quot;,&quot;blue&quot;,&quot;green&quot;);

</font></pre>
    </blockquote>
    <p>现在你就有了一个数组,你能对它做什么呢?数组的优点在于<br>
    数组中的各个元素可以通过数字调用。第一个元素的数字是<font
    face="宋体">0</font>,<br>
    可以用以下方式调用: </p>
    <blockquote>
      <pre>
<font face="宋体">var the_element = colors[0];

</font></pre>
    </blockquote>
    <p>执行这一行<font face="宋体">JavaScript</font>指令时,变量<tt><font
    face="宋体">the_element</font></tt>所被赋予的值<br>
    是字符串<font face="宋体">&quot;red&quot; </font>。通过写出数组的名称并将数组中元素的顺序号<br>
    放在方括号内就可调用数组中的该元素。数组中第<font face="宋体">2</font>个元素的顺<br>
    序号是<font face="宋体">1</font>。 </p>
    <p>一旦生成数组后,你可以添加和修改数组值。如果你打算将颜<br>
    色数组的第<font face="宋体">1</font>个元素有红色该为紫色,你可以这样做:</p>
    <p><br>
    <font face="宋体">colors[0] = &quot;purple&quot;;<br>
    <br>
    </font></p>
    </font><p><font SIZE="3">数组经常用于循环。下文将讲<a href="day4_9.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_9.html">数组和循环</a>的应用。</font></p>
    <p align="left"><font face="宋体" size="3" color="#000000"><strong>JavaScript教程</strong></font><font
    color="#FF0000" face="宋体" size="3"><br>
    </font><font size="3" color="#FF0000">第一页</font><font size="2" face="宋体"> </font><a
    href="day4_8.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_8.html"><font SIZE="3">第四课介绍</font></a><font size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第二页</font> <a href="day4_2.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_2.html">循环介绍</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第三页</font> <a href="day4_3.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_3.html">循环的密码</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第四页</font> <a href="day4_4.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_4.html">再谈<font
    face="宋体">WHILE</font>循环</a></font><font size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第五页</font> <a href="day4_5.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_5.html">For循环</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第六页</font> <a href="day4_6.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_6.html">嵌套循环</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第七页</font> <a href="day4_7.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_7.html">循环练习</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第八页</font> 数组</font><font size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第九页</font> <a href="day4_9.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_9.html">数组和循环</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第十页</font> <a href="day4_10.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_10.html">文件目标模块中的数组</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第十一页</font> <a href="day4_11.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_11.html">函数</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第十二页</font> <a href="day4_12.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_12.html">无参数函数</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第十三页</font> <a href="day4_13.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_13.html">参数及返回值</a></font><font
    size="2"><br>
    </font><font SIZE="3"><font color="#FF0000">第十四页</font> <a href="day4_14.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day4_14.html">多于一个参数的函数</a></font></p>
    <p align="left"><font face="宋体" size="3">[<a href="index.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/index.html">第1课</a>][<a
    href="day2_1.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day2_1.html">第2课</a>][<a href="day3_1.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day3_1.html">第3课</a>][第4课][<a
    href="day5_1.html" tppabs="http://www.pchome.net/ch/tur/pstext/teacher/javascript/day5_1.html">第5课</a>]</font></p>
    <hr align="left">
    <p><font size="2">本文由<a href="javascript:if(confirm('http://chd.126.com/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://chd.126.com/'" tppabs="http://chd.126.com/" target="_blank">《</font><font
    face="verdana, arial, geneva, sans-serif" size="2">CHD</font><font size="2">的网络教室》</a>根据<a
    href="javascript:if(confirm('http://www.webmonkey.com.cn/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.webmonkey.com.cn/'" tppabs="http://www.webmonkey.com.cn/" target="_blank">《网猴》</a>相关文章改编,版权归<a
    href="javascript:if(confirm('http://www.webmonkey.com.cn/  \n\nThis file was not retrieved by Teleport Pro, because it is addressed on a domain or path outside the boundaries set for its Starting Address.  \n\nDo you want to open it from the server?'))window.location='http://www.webmonkey.com.cn/'" tppabs="http://www.webmonkey.com.cn/" target="_blank">《网猴》</a>所有</font></td>
  </tr>
</table>
</div>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -