<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                #### 一、語句和表達式 任何語句都有返回值,也就是你在控制臺按下回車時控制臺打印出的結果。變量聲明返回的是undefined,執行一個函數如果有return的話則打印return的值,否則依舊是undefined ``` var a = 42; //undefined b = 2; //2 function func() { a = 43;} //undefined func(); //undefined function func1() {return 42;} func1(); //42 ``` 逗號可以將多個獨立的語句串成一個表達式 ``` var a = 42; var b = (a++, a); //相當于a++;var b = a; a; //43 b; //43 ``` 組合賦值運算符總是從右往左 ``` a = b += 2; //先執行b += 2,然后執行a = b a = b = c; //先執行b = c,然后執行a = b var a = b = 42; //如果b從未聲明過,則b會稱為全局變量 ``` 讓代碼更加簡潔 ``` function func(str) { var matches; if(str) { matches = str.match(/\d/g); if(matches) return matches; } } //簡化 function func(str) { var matches; if(str && (matches = str.match(/\d/g))) return matches; } ``` 代碼塊 ``` //[]和{}均被轉成字符串 [] + {}; //"[object Object]" //{}被當成空代碼塊,該語句相當于變成了+[] {} + []; //0 ``` js是沒有else if的 ``` else if(b) {...} //其實是 else { if(b) {... } } ``` #### 二、運算符優先級 && > || > ?和: ``` a && b || c ? c || b ? a : c && b : a (a && b || c) ? (c || b) ? a : (c && b) : a ((a && b) || c) ? ((c || b) ? a : (c && b)) : a ``` #### 三、自動分號 #### 四、錯誤 #### 五、函數參數 #### 六、try catch finally 無論try catch中有何種語句(包括return),最終都會走到finally。 ``` function func() { try {return 42;} finally {console.log('hello')} } func(); //'hello' //42 //try語句會先執行并return 42,由于還有finally存在,函數要在finally執行完后才能return ``` ``` //throw和return同理,continue和break也是一樣,都是finally完后才執行 function func() { try {throw 42;} finally {console.log('hello')} } func(); //'hello' //Uncaught Exception: 42 ``` ``` //如果finally中有異常,則try中的return將會被丟棄 function func() { try {return 42;} finally {throw 42;} } func(); //Uncaught Exception: 42 ``` switch特殊用法 ``` switch(true) { case a == 10: ... break; case a == 11: ... break; default: break; } ```
                  <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>

                              哎呀哎呀视频在线观看