<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國際加速解決方案。 廣告
                [TOC] * * * * * ### 1. 定義 ~~~ Array.prototype.map( callback(currentValue, index, array), thisArg ) 創建一個新數組,其結果是該數組中的每個元素都調用一個回調函數后返回的結果。 PS:原數組不變,返回一個新數組。 ~~~ * * * * * ### 2. 參數 ~~~ 該函數的參數有兩個: 第一個是回調函數,該函數的入參有三個,currentValue 為當前元素,index 當前元素索引,array 原數組。返回值為處理后的新元素; 第二個 thisArg 是一個對象,可選的。執行 callback 函數時 使用的 this 值,如果不指定就上層執行作用域; PS:需要注意的是,指定的 this 值并不一定是該函數執行時真正的 this 值。 如果函數處于非嚴格模式下: a. 指定為 null 和 undefined 的 this 值會自動指向全局對象(瀏覽器中就是 window 對象) ; b. 如果值為原始值(數字,字符串,布爾值)的,this會指向該原始值的自動包裝對象。 ~~~ * * * * * ### 3. 面試題 ~~~ 題 1: [' a b','23 '].map(Function.prototype.call, String.prototype.trim) 可以猜測代碼的意思就是對原數組中的每個元素去除首尾的空格后返回組成的新數組。 這里的 call 函數綁定的執行環境對象就是 String.prototype.trim 每一次迭代的操作如下: String.prototype.trim.call(currentValue) ~~~ >[danger] 有些回調函數,`this` 是用在函數體內的, 有些函數,如 `trim,toLowerCase` 等 `this` 是作為該函數的調用作用域 ~~~ 題 2: ["A","B","C"].map(String.prototype.toLowerCase.call); // --> TypeError: undefined is not a function 這里沒有指定 thisArg,那么默認就是 undefined String.prototype.toLowerCase.call===Function.prototype.call ~~~ >[info]驗證: ![](https://box.kancloud.cn/d9ef36862a55aa2875198070d721dfcf_697x215.png) >[info] 結論: >[success] 從上面可以看到,`map` 的第一個參數,其實就是 `call` 函數,只是引用的方式不同,這個函數必須要有 `this` 去調用它,且類型得為 `Function` 的
                  <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>

                              哎呀哎呀视频在线观看