<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??碼云GVP開源項目 12k star Uniapp+ElementUI 功能強大 支持多語言、二開方便! 廣告
                [TOC] # 1. 變量的定義與語法 ## 案例1:變量類型及定義 >![](https://img.kancloud.cn/6e/70/6e7078b98a8a36cf1584c31eefd3694a_526x435.png) > 定義了變量但是沒有賦值**undefined** > 定義了對象但是可以設置為**null**表示空對象 ### 試一試 ![](https://img.kancloud.cn/0d/6d/0d6da420ec2739908ee7ea2ac180982d_486x262.png) > 比一比、試一試 ``` var a = (); var b=[]; var c = {}; ``` ### 擴展:變量的類型的判斷 | 方法名 | 描述 | | --- | --- | | **typeof X** | 判斷X的所屬類型 | ``` typeof 1 typeof '1' typeof true typeof …… ``` **typeof的返回值說明** | 類型 | 說明 | | --- | --- | | number | 數字 | | String| 字符串 | | Boolean| 布爾| | function| 函數 | | object| 對象| | undefined| 未定義| ## 案例2:變量作用域與提升 * [ ] 變量可以不聲明,直接使用 * [ ] 不聲明的變量默認為全局變量 ![](https://img.kancloud.cn/ae/45/ae4524813d08c009ab1b4b5ee25279bc_372x371.png) # 2. JS運算及語法結構 ## 案例3:JavaScript運算 * 一元運算 * 算術運算 ![](https://img.kancloud.cn/d5/82/d582a61738afde88f44e4f08ec5f66b5_379x204.png) * 移位運算 * 關系運算 * 布爾運算 ![](https://img.kancloud.cn/47/39/473995947ea10097281c76b0d533e330_387x131.png) * 位操作運算 * 邏輯運算 * 賦值運算 > ## 案例4:JavaScript語句結構 * [ ] **if/else、switch** * [ ] **for、while、do{}while()** ### 試一試 > 向網頁中輸出九九乘法表(實驗1) ![](https://img.kancloud.cn/5c/ae/5cae09cdbe63811c252cb4e7c3b8453b_487x205.png) # 3. 基礎數據類型 ## 案例5:不一樣的數字(number) > 1. 常規十進制 > 2. 以0x開頭的十六進制 > 3. 以0開頭的八進制 > 4. 添加e的科學計數法 > 5. 當無法計算數值時,結果是**NaN** > 6. 無窮大**Infinity** ![](https://img.kancloud.cn/56/9e/569ef3beb6ffb25727c018cff00b74ed_399x289.png) ## 案例6:加引號的字符串(string) ![](https://img.kancloud.cn/d1/be/d1bef446d24209ab47a6c28d74a8da2b_474x259.png) > 轉義字符 > 1. 換行`\n` > 2. 單引號`\'` > 3. 雙引號`\"` > 4. 反斜杠`\\` ![](https://img.kancloud.cn/f9/d2/f9d2268832b7092cd9e1a0f9a89c5e11_398x157.png) ## 案例7:參與運算的布爾(boolean) > 1. 取值**true**和**false** > 2. 必要時,參與運算時,**true視為1,false視為0。** ![](https://img.kancloud.cn/a1/23/a123af3cc22b83965352cf98f105ddf9_394x160.png) # 4. 基礎數據類型的相互轉換 | 方法名 | 描述 | | --- | --- | | **Number(X)** | 將X轉換為number類型 | | **parseInt(X)** | 解析X字符串并返回一個整數 | | **parseFloat(X)** | 解析X字符串并返回一個浮點數 | | **String(X)** | 將X轉換為字符串 | | **Boolean(X)** | 將X轉換為Boolean類型 | ## 案例8-1:數字轉字符串 ![](https://img.kancloud.cn/7e/40/7e40fa4d266c12184d324d078dcef08b_287x279.png) ## 案例8-2:字符串轉數字 ![](https://img.kancloud.cn/35/ec/35ec5bb13bd57d59c640fb294bcd7dfc_288x299.png) ***** ![](https://img.kancloud.cn/3a/f2/3af24849285eb47c1b0eb9c6c5abc23a_481x143.png) ## 案例8-3:轉boolean ``` 0 、空串 、null、 undefined 、NaN是false ``` ![](https://img.kancloud.cn/c7/0a/c70a07cec7546c2353b3f5b0f2b8d8bc_329x300.png) ## 案例8-4:==判斷 ![](https://img.kancloud.cn/1d/4b/1d4be1d26870b0340d14615b0d91b671_805x688.png) ![](https://img.kancloud.cn/08/21/08210a6f60880660805ef25828de77ef_516x208.png) ***** ![](https://img.kancloud.cn/f6/e1/f6e135f6b1d7ba3213864d18fe225507_477x495.png) ## 特殊類型:null和undefined > undefined 未定義 > null 定義為object,但是對象為空 # 5. 函數(function) ## 案例9:函數的定義 ![](https://img.kancloud.cn/3e/8c/3e8cb751697f94fd7cf7f42dac1e213d_711x300.png) ## 試一試:輸出任意數字乘法表 ![](https://img.kancloud.cn/a6/d6/a6d692650193d5a3ab110eb5fca146cb_755x511.png) ## 案例10:函數調用及傳參 * 通過函數名調用 * 自執行函數 * 通過事件調用 * 通過鏈接調用 ![](https://img.kancloud.cn/dd/54/dd54b05a869f38a9e7d922a9a6de6960_533x443.png) > 可以將超鏈接與事件結合,能夠有效隱藏超鏈接的URL`<a href="#" onclick="test()">test</a>` > 函數形參不需要var * 不給參數傳遞值,參數值為undefined > 函數返回值需要return * 使用無返回類型函數給變量賦值,變量值變為undefined ![](https://img.kancloud.cn/22/c5/22c5f665cdc350ac3e7ee19369bb22fe_372x379.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看