<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] >[success] # 參數解構 傳遞函數參數時。當 JS 的函數接收大量可選參數時,一個常用模式是創建一個 options 對象,其中包含了附加的參數 >[success] ## ES5參數解構 ~~~ 下面這種方法很有用,但無法僅通過查看'函數定義'就判斷出函數所期望的輸入,你必須閱讀'函數體'的代碼。 ~~~ ~~~ // options 上的屬性表示附加參數 function setCookie(name, value, options) { options = options || {} let secure = options.secure, path = options.path, domain = options.domain, expires = options.expires; console.log(options) } // 第三個參數映射到 options setCookie("type", "js", { secure: true, expires: 60000 }) ~~~ <br/> >[success] ## ES6參數解構 ~~~ // name, value代表必傳,第三個參數代表不必傳 function setCookie(name, value, { secure, path, domain, expires } = {}) { // 設置 cookie 的代碼 console.log(secure) // true console.log(expires) // 60000 } setCookie("type", "js", { secure: true, expires: 60000 }) 或者'數組參數解構' let a = 1, b = 2 function test([b,a] = []){ console.log(b,a) // 1 2 } test([a,b]) ~~~ <br/> >[success] ## 參數解構默認值 ~~~ 你可以為'參數解構'提供可解構的'默認值',就像在'解構賦值'時所做的那樣,只需在其中每個參數后面添加 '等號'并指定'默認值'即可。例如: ~~~ ~~~ function setCookie(name, value, { secure = false, path = "/", domain = "example.com", expires = new Date(Date.now() + 360000000) } = {} ) { console.log(secure) // 1 console.log(path) // example.com console.log(domain) // 22 // 代碼... } setCookie('小明','100歲',{secure:1,path:22}) ~~~
                  <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>

                              哎呀哎呀视频在线观看