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

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                ~~~ /* * 需求一:獲取數組中的最大值(最小值) * 1.給數組先排序(由大到小排序),第一項就是最大值 * 2.假設法:假設第一個值是最大值,依次遍歷數組中后面的每一項, * 和假設的值進行比較,如果比假設的值要大,把當前項賦值給MAX... * 3.基于Math.max完成 */ let ary = [12, 13, 14, 23, 24, 13, 15, 12]; //=>Math.max // console.log(Math.max(ary));//=>NaN =>Math.max是獲取一堆數中的最大值, 需要我們把比較的數,一個個的傳遞給這個方法 =>Math.max(12,13,14...) =>Math.max([12,13,14...])這樣只是傳遞一個值 /* [12,13,14].toString() =>"12,13,14" eval("12,13,14") =>14 ~~~ ![](https://img.kancloud.cn/f7/de/f7def9660a09d9aac465532e757e85f2_268x93.png) ~~~ 1.eval:把字符串轉換為JS表達式 eval("1+2") =>3 2.括號表達式(小括號的應用) 用小括號包起來,里面有很多項(每一項用逗號分隔), 最后只獲取最后一項的內容(但是會把其它的項也都過一遍) (function(){ console.log(1); },function(){ console.log(2); })(); =>2 ~~~ ![](https://img.kancloud.cn/09/72/0972028b251a9e1523ca5c3b252fb268_470x356.png) ~~~ let a=1===1?(12,23,14):null; =>a=14 ~~~ ![](https://img.kancloud.cn/58/d2/58d2eee22ce2374acad8e6a643147128_528x152.png) ~~~ 不建議大家過多使用括號表達式,因為會改變THIS */ /*let fn=function(){console.log(this);} let obj={fn:fn}; (fn,obj.fn)();//=>執行的是第二個OBJ.FN, 但是方法中的THIS是WINDOW而不是OBJ (obj.fn)();//=>this:obj*/ //=>基于EVAL轉換字符串為JS表達式 // console.log(eval("Math.max(" + ary.toString() + ")")); //=>利用了APPLY的一個特征:雖然放的是一個數組, 但是執行方法的時候,也是把數組中的每一項一個個的傳遞給函數 // console.log(Math.max.apply(null, ary)); //=>排序 /* let max = ary.sort(function (a, b) { return b - a; })[0]; console.log(max); */ //=>假設法 /* let max = ary[0]; for (let i = 1; i < ary.length; i++) { let item = ary[i]; item > max ? max = item : null; } console.log(max); */ ~~~
                  <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>

                              哎呀哎呀视频在线观看