欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript的學(xué)習(xí)入門(mén)整理篇第1/3頁(yè)

 更新時(shí)間:2008年09月24日 23:22:09   作者:  
每次剛開(kāi)始學(xué)語(yǔ)言時(shí),作者都喜歡用“hello world”例子l來(lái)侮辱我們的智商,我想大家都不是笨蛋,故而寥寥數(shù)筆寫(xiě)了一點(diǎn)
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=gb2312">
<title>Document.writeln()方法</title>
<script language="javascript">
function createsummary()
{
     win2
=open("","window2")
     
//win2.document.open("text/plain")
     win2.document.writeln("title"+document.title)
     win2.document.close()
}
</script>
</head>
<body>
<a name="#top"></a>
    
<form>
       
<input type="button" name="help" value="help"onClick="createsummary()">
    
</form>
<body>
</html>

說(shuō)一下知識(shí)要點(diǎn)吧:

1:JavaScript是一種區(qū)分大小寫(xiě)的語(yǔ)言。

2:建議每寫(xiě)一行要用‘;';

3:命名第一個(gè)字母必須是字母、下劃線或‘$';

4:在JavaScript中聲明變量用var,而且是永久性的;

5:沒(méi)有塊級(jí)作用域。例如:

Var scope="globle";
function f(){
    alert(scope);  
//顯示“underfined"而不是"globle"
    Var scope="local";
    alert(scope);
}
F();
與下面的代碼實(shí)例意義相同
Var scope="globle";
function f(){
    Var scope;
    alert(scope);  
//顯示“underfined"而不是"globle"
    Var scope="local";
    alert(scope);
}
F();

建議:將所有的變量聲明集中起來(lái)放置在函數(shù)的開(kāi)頭是一個(gè)很好的編程習(xí)慣。

6:ECMAScript標(biāo)準(zhǔn)中規(guī)定函數(shù)不能重載,例如

 

function doadd(i){
       alert(i);
}

function doadd(i){
       alert(i);
}
doadd(
10);

真正執(zhí)行的是后一個(gè)函數(shù),第二個(gè)覆蓋了第一個(gè)函數(shù);

7:arguments對(duì)象的使用。

function doAdd()
   If(arguments.length
==1){
      alert(arguments[
0]+10);
}

   If(arguments.length
==2){
      alert(arguments[
0]+arguments[0);
}

doAdd(
10);
doAdd(
10,20);

運(yùn)行效果:略……

相關(guān)文章

最新評(píng)論