国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

JavaScript的學習入門整理篇第1/3頁

2024-05-06 14:17:11
字體:
來源:轉載
供稿:網友
<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>

說一下知識要點吧:

1:JavaScript是一種區分大小寫的語言。

2:建議每寫一行要用‘;';

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

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

5:沒有塊級作用域。例如:

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

建議:將所有的變量聲明集中起來放置在函數的開頭是一個很好的編程習慣。

6:ECMAScript標準中規定函數不能重載,例如

 

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

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

真正執行的是后一個函數,第二個覆蓋了第一個函數;

7:arguments對象的使用。

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

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

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

運行效果:略……
123下一頁閱讀全文

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 肃宁县| 禄劝| 广南县| 洛扎县| 宕昌县| 商水县| 宝应县| 罗江县| 霍邱县| 常宁市| 荃湾区| 调兵山市| 泸定县| 砚山县| 陆丰市| 进贤县| 永安市| 福海县| 喀什市| 明光市| 花莲县| 阳曲县| 壶关县| 敦煌市| 峨眉山市| 莒南县| 安岳县| 迭部县| 秀山| 镇远县| 巴塘县| 开远市| 腾冲县| 沈丘县| 正定县| 县级市| 鞍山市| 当阳市| 龙里县| 项城市| 诸城市|