<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國際加速解決方案。 廣告
                **1、函數參數的默認值** 函數的參數支持默認值,如果有多個值,要傳參時,只能省略最后一個 ``` function str(x=10,y=20) { console.log(x, y); }; str(100);//100 20 ``` 如果非要傳y,可采用對象的形式來寫 ``` function str({x,y=20}) { console.log(x, y); } //str();//報錯 //str({y:50});//undefined 50 str({});//undefined 20 x沒有默認值會輸出undefined ``` **2、函數參數的rest參數 把剩余的參數包裝到數組里** ``` function arr(x,y,...args) { //console.log(x);//1 //console.log(y);//2 //console.log(args);//[3,4,5] console.log(arguments);//實參個數 是object對象,也是偽數組,不能使用數組的方法 args.forEach(function (item,i) { console.log(item);//3 4 5 }) } arr(1,2,3,4,5) ``` 3、箭頭函數 有兩種函數的寫法 函數的聲明–>箭頭函數不能用于有名函數 函數的表達式 ``` let add = (x,y) => { return x+y; } //let add = (x,y) => x+y; console.log(add(10, 20));//30 //等效 function add(x,y){return x+y;} ``` 簡寫:只有一個參數,可以省略() ``` let add = x =>{return x;} //let add = x =>x; console.log(add(50));//50 //等效 function add(x){return x;} ``` 簡寫:當函數體只有一條語句時,后面表達式的值直接可以作為返回值 ``` let add = (x,y) => x+y; console.log(add(10, 20));//30 //等效 function add(x,y){return x+y;} ``` 匿名函數: ``` var arr = [1,2,3,4]; //function(){} arr.forEach(function (item,i) { console.log(item); }) //es6: //()=>{} arr.forEach((item,i) => { console.log(item); }) //簡寫:x=>x省略括號(一個參數,當函數體只有一條語句時) arr.forEach(item => console.log(item)); ``` 4、箭頭函數中的this ``` //es5: function F() { console.log(this);//實例對象F var that = this; setTimeout(function () { console.log(this);//window console.log(that);//實例對象F },100); }; var per = new F(); function Fo() { console.log(this);//實例對象Fo var that = this; setTimeout(function () { console.log(this);//window console.log(that);//實例對象Fo }.bind(this),100); }; var per1 = new Fo(); //es6: function Foo() { setTimeout(() => { console.log(this);////實例對象Foo },1000) } var per2 = new Foo(); ```
                  <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>

                              哎呀哎呀视频在线观看