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

📄 day5_5.html

📁 JAVASCRIPT 高级编程
💻 HTML
📖 第 1 页 / 共 2 页
字号:
    </td>
  </tr>
  <tr> 
    <td colspan="2" align="center" bgcolor="#666699"><a href="../../1-teach/index.htm"><font color="#FFFFFF">实用技巧</font></a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/internet/index.htm">Internet应用</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/photoshop/index.html">Photoshop</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/flash/page1.html">Flash</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/asp/index.html">ASP</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/php/index.html">PHP</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/java/index.htm">Java</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/vb/index.htm">VB</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/c/index.htm">C、C++</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-backend/database/php_mysql/index.html">PHP/MySQL</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2"><a href="../../1-backend/cgi_perl/perl_beginner/index.html">-Perl</a> 
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2">-<a href="../../1-teach/other/index.htm">其它</a> </td>
  </tr>
  <tr> 
    <td colspan="2" bgcolor="#666699"> 
      <div align="center"><font color="#FFFFFF">更多教程</font></div>
    </td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="17"><a href="../../1hdml/index.html">-HDML</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="23"><font face="宋体"><a href="../../1-backend/database/course/day1_1.html">-网络数据库</a></font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="14"><a href="../../1-backend/protocols/ping/index.html"><font face="arial, helvetica, sans-serif">-ping</font></a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="20"><a href="../../1-backend/cgi_perl/search_engine/index.html">-创建搜索引擎</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" height="16">-<a href="../../1adobe/GoLive/index.html">Adobe GoLive</a></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2"><a href="../../1-backend/cgi_perl/templates/index.html">-模板</a></td>
  </tr>
  <tr bgcolor="#666699"> 
    <td colspan="2" align="center"><font color="#FFFFFF">合作伙伴</font></td>
  </tr>
  <tr bgcolor="#FFFFFF"> 
    <td colspan="2" align="left">-<a href="http://www.5dmedia.com/" target="_blank">5D精英网</a></td>
  </tr>
  <tr align="center" bgcolor="#FFFFFF"> 
    <td colspan="2"> <img src="../../Library/front_monkey.gif" width="59" height="68"></td>
  </tr>
  </tbody> 
</table>
<!-- #EndLibraryItem --> </td>
 <!-- End of headlines (column 1: left column) --> <!-- Gutter between columns 1 and 2 --> 
 <td width="10" height="794"><img src="http://www.sohu.com/images/pixel.gif" width=10></td>
 <!-- Search box and directories (columns 2 and 3: middle columns, combined into one) --> 
 <td align=center valign=top width="558"> 
 <div align="left"><!-- #BeginEditable "1" --> 
<title>JavaScrip高级教程</title>
 <strong>第五页:<font size="3">好的编程实践</font></strong> 
      <p>编好程序的关键是程序是写给人的,不是写给计算机的。如<br>
        果你能明白其他人或许会阅读你的JavaScript,你就会写更<br>
        清晰的代码。代码越清晰,你就越不容易犯错误。机灵的代<br>
        码是可爱的,但就是这种机灵的代码会产生错误。最好的经<br>
        验法则是KISS,即Keep It Simple,Sweetie(保持简单,可爱)。</p>
      <p>另一个有帮助的技术是在写代码之前作注释。这迫使你在动<br>
        手之前先想好。一旦写好了注释,你就可以在其下面写代码。<br>
        下面是一个用这种方法写函数的例子:</p>
      <p><strong>第一步:写注释</strong></p>
      <blockquote> 
        <pre>//function beSassy()
//  beSassy asks for a user's name, chooses a random 
//  insult and returns an alert box with the user's name and the
//  insult.
function beSassy()
{
	//  first write a list of insults
	//

	//  next get the user's name
	//

	//  then choose a random insult  
	//

	//  finally, return the personalized sass
	//
}</pre>
      </blockquote>
      <p><strong>第二步:填充代码</strong></p>
      <blockquote> 
        <pre>//function beSassy()
//  beSassy asks for a user's name, chooses a random 
//  insult and returns an alert box with the user's name and the
//  insult.
function beSassy()
{
	//  first write a list of insults
	//
	var the_insult_list = new Array;
	the_insult_list[0] = &quot;your shoe lace is untied&quot;;
	the_insult_list[1] = &quot;your mama!&quot;;
	the_insult_list[2] = &quot;it's hard to be insulting&quot;;

	//  next get the user's name
	//
	var the_name = prompt(&quot;What's your name?&quot;, &quot;&quot;);

	//  then choose a random insult  
	//
	var the_number =  Math.random() * 5;
	var insult_number = parseInt(the_number);
	var the_insult = the_insult_list[insult_number];

	//  finally, return the personalized sass
	//
	alert(&quot;Hey &quot; + the_name + &quot; &quot; + the_insult);
}</pre>
      </blockquote>
      <blockquote> 
        <p>这种先写注释的策略不仅迫使你在写代码前思考,而且<br>
          使编码的过程看起来容易些 - 通过把任务分成小的,<br>
          易于编码的各个部分,你的问题看起来就不太象珠穆朗<br>
          玛峰,而象一群令人愉悦的起伏的小山。</p>
      </blockquote>
      <p><strong>最后...</strong></p>
      <p>总以分号结束你的每一条语句。</p>
      <blockquote> 
        <p>虽然并不是严格必需,你应该养成以分号结束每一条语<br>
          句的习惯,这样可以避免这行后面再有代码。忘了加<br>
          分号,下一行好的代码会突然产生错误。</p>
      </blockquote>
      <p>把变量初始化为“var”,除非你有更好的理由不这样做。</p>
      <blockquote> 
        <p>用“var”把变量局域化可以减少一个函数与另一个不相<br>
          关函数相混淆的机会。</p>
      </blockquote>
      <p>好了,既然你已经知道了如何编码,下面就让我们学习怎样使<br>
        你的JavaScript快速运行。<a href="day5_6.html">&gt;&gt;</a></p>
      <p align="left"><font face="宋体" size="3" color="#000000"><strong>JavaScript高级教程</strong></font><font color="#FF0000" face="宋体" size="3"><br>
        </font><font color="#FF3300" size="3">第一页</font><font size="3"> </font><a href="day5_1.html"><font size="3" face="verdana, arial, geneva, sans-serif">JavaScript</font><font size="3">高级教程</font><font size="3" face="verdana, arial, geneva, sans-serif">- 
        </font><font size="3">第</font><font size="3" face="verdana, arial, geneva, sans-serif">5</font><font size="3">天</font></a><font size="3"> 
        <br>
        </font><font color="#FF3300" size="3">第二页 </font><font size="3"><a href="day5_2.html">打印变量</a><br>
        </font><font color="#FF3300" size="3">第三页 </font><font size="3"><a href="day5_3.html">一般性程序错误</a><br>
        </font><font color="#FF3300" size="3">第四页 </font><font size="3"><a href="day5_4.html">修正错误</a><br>
        </font><font color="#FF3300" size="3">第五页 </font><font size="3">好的编程实践<br>
        </font><font color="#FF3300" size="3">第六页 </font><font size="3"><a href="day5_6.html">按速度优化JavaScript代码</a><br>
        </font><font color="#FF3300" size="3">第七页 </font><a href="day5_7.html"><font size="3">下面讲什么?</font></a></p>
      <p align="left">[<a href="day1_1.html">第1课</a>][<a href="day2_1.html">第2课</a>][<a href="day3_1.html">第3课</a>][<a href="day4_1.html">第4课</a>][第5课]</p>
      <!-- #EndEditable --></div>
 </td>
 <!-- End of search box and directories (columns 2 and 3: middle columns, combined into one) --> 
 <!-- Gutter between columns 3 and 4 --> <!-- Other stuff (column 4: right column) --> 
 <!-- End of other stuff (column 4: right column) --> </tr>
 </table>
<!-- End of table surrounding page contents -->

 <hr noshade size=1 width=700>
 <span class=eng><br>
 Copyright (C) 1998-2000 Internet Technologies China.&nbsp; All rights reserved. 
 </span> 
</center>
</body>
<!-- #EndTemplate --></html>

⌨️ 快捷键说明

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