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

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                * [強制] 在相等表達式 中使用類型嚴格的 === , 僅當判斷null或者undefined時,使用==, 使用===可以避免等于判斷中隱式的類型轉換 ``` // good if (age === 30) { // ...... } // bad if (age == 30) { // ...... } ``` * 不過還是建議盡量使用===,== 可能會帶來一些違反直覺的后果。比如我們常使用的對象,有時獲取不到而被賦值為undefine的情況。 ``` var obj = undefined; if(obj == null){ console.log("1"); // 執行 } if(obj === null){ console.log("2"); // 不執行 } ``` * [建議] 盡可能使用簡潔的表達式。 ``` // 字符串為空 // good if (!name) { // ...... } // bad if (name === '') { // ...... } // 字符串非空 // good if (name) { // ...... } // bad if (name !== '') { // ...... } // 數組非空 // good if (collection.length) { // ...... } // bad if (collection.length > 0) { // ...... } // 布爾不成立 // good if (!notTrue) { // ...... } // bad if (notTrue === false) { // ...... } // null 或 undefined // good if (noValue == null) { // ...... } // bad if (noValue === null || typeof noValue === 'undefined') { // ...... } ``` * [建議] 對于相同變量或表達式的多值條件,用 switch 代替 if。 ``` // good switch (typeof variable) { case 'object': // ...... break; case 'number': case 'boolean': case 'string': // ...... break; } // bad var type = typeof variable; if (type === 'object') { // ...... } else if (type === 'number' || type === 'boolean' || type === 'string') { // ...... } ``` * [建議] 如果函數或全局中的 else 塊后沒有任何語句,可以刪除 else。 ``` // good function getName() { if (name) { return name; } return 'unnamed'; } // bad function getName() { if (name) { return name; } else { return 'unnamed'; } } ```
                  <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>

                              哎呀哎呀视频在线观看