<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 功能強大 支持多語言、二開方便! 廣告
                >[success] # Function -- arguments 1. **arguments** 是一個 對應于 傳遞給函數的參數 的 **類數組 array-like**對象 2. **arguments** 只是像數組結構一種對象,因此他不具備數組的方法,如**filter、map**,但其自身是有**length**,且也是**可迭代對象**,因此可以使用**index** 依次獲取或者 **of**循環可迭代對象 3. **arguments** 獲取是是實際傳入參數個數 ~~~ function a(p1, p2, p3, p4 = 4, ...args) { console.log(arguments) console.log(arguments.length) } a() // [Arguments] {} 0 a(1, 2) // [Arguments] { '0': 1, '1': 2 } 2 a(1, 2, 3, 4, 5, 6, 7) // [Arguments] { '0': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 6, '6': 7 } 7 ~~~ >[danger] ##### arguments轉Array 1. 遍歷arguments,添加到一個新數組中 2. 調用數組**slice**函數的call方法 3. ES6 **Array.from** 和 **解構賦值** ~~~ function a(p1, p2, p3, p4 = 4, ...args) { const newLs1 = [] for (let item of arguments) { newLs1.push(item) } // es6 const newLs2 = Array.from(arguments) const newLs3 = [...arguments] // 改變this 指向 等同 [].slice.call(arguments) const newLs4 = Array.prototype.slice.call(arguments) const newLs5 = Array.prototype.splice.call(arguments, 0) console.log(newLs1) console.log(newLs2) console.log(newLs3) console.log(newLs4) console.log(newLs5) } a(1, 2, 3, 4, 5, 6, 7) ~~~ >[danger] ##### 箭頭函數不綁定arguments 1. 箭頭函數沒有**arguments** 屬性 ~~~ function a(p1, p2, p3, p4 = 4, ...args) { return (a1) => { console.log(arguments) // 箭頭函數沒有arguments 熟悉因此獲取當前this為最外層函數的 } } a(1, 2, 3, 4, 5, 6, 7)(10) // [Arguments] { '0': 1, '1': 2, '2': 3, '3': 4, '4': 5, '5': 6, '6': 7 } ~~~ >[info] ## 使用es6 剩余參數 還是es5 arguments 1. 剩余參數只**包含那些沒有對應形參的實參**,剩余參數是一個真正的數組,可以進行**數組的所有操作** 2. **arguments** 對象包含了**傳給函數的所有實參**; arguments對象**不是一個真正的數組** 3. arguments是早期的ECMAScript中為了方便去獲取所有的參數提供的一個數據結構,而rest參數是ES6中提供并且希望以此來替代arguments的
                  <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>

                              哎呀哎呀视频在线观看