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

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ~~~ <script> /* * 獲取數組中指定項的索引 * indexOf([item]):獲取當前項在數組中第一次出現位置的索引 * lastIndexOf([item]) :獲取當前項在數組中最后一次出現位置的索引 * includes:驗證數組中是否包含這一項,返回TRUE/FALSE * 原始數組不變 */ // let arr = [10, 20, 30, 10, 20, 10, 30]; // console.log(arr.indexOf(20)); //=>1 // console.log(arr.lastIndexOf(20)); //=>4 // console.log(arr.indexOf(40)); //=>-1 如果數組中不包含這一項,則返回結果是-1 // =>基于這個特征來驗證數組中是否包含某一項 // if (arr.indexOf(40) > -1) { // // 數組中包含這一項 // } // console.log(arr.includes(40)); </script> <script> /* * reverse:把原始數組倒過來排列,返回的結果是排列后的原始數組,原始數組改變 * * sort:把原始數組按照規則進行排序,原始數組會改變(返回結果也是改變后的原始數組) * SORT支持傳遞回調函數,基于自定義的排序規則,進行排序的 */ // let arr = [4, 3, 2, 5, 1]; // arr.reverse(); // console.log(arr); ~~~ ![](https://img.kancloud.cn/ef/9f/ef9f018ceeb41f811deccfcc72f154e8_408x109.png) ~~~ // arr.sort(); //=>默認按照由小到大排序 // console.log(arr); //=>[1,2,3,4,5] // let arr = [12, 23, 110, 34, 2, 4, 9]; // arr.sort(); //=>SORT排序,默認不就是按照每一項的數值大小排序,而是按照每一項的每一個字符編碼來進行比較排序的,所以導致直接寫SORT,不能處理兩位及兩位以上的內容排序 // console.log(arr); //=>[110, 12, 2, 23, 34, 4, 9] // let arr = [12, 23, 110, 34, 2, 4, 9]; // arr.sort(function (a, b) { // // => RETURN A-B 升序,B-A 降序 // return b - a; // }); // console.log(arr); //=>[2, 4, 9, 12, 23, 34, 110] </script> ~~~ ![](https://img.kancloud.cn/8c/5e/8c5ea15950e677712e895c55f1b7b35c_340x108.png) ~~~ <script> /* * 數組中常用的迭代方法(遍歷數組中每一項的) * forEach([函數]):遍歷數組中的每一項(數組中有多少項,函數會相繼被執行多少次),每一次執行函數,都可以在函數中獲取到當前遍歷的這一項和對應的索引 * map:forEach是不支持返回值的,而map可以在forEach的基礎上支持返回值,把原來數組中每一項的值替換成為新值,最后存儲在一個新的數組中,但是原始數組是不變的 * * 后面再學習的迭代方法:find / filter / every / some / reduce ... */ // let arr = [10, 20, 30, 40, 50]; // ===========數組就和的方式 // console.log(eval(arr.join('+'))); 如果數組中出現非有效數字,則最后結果是NaN /* let total = 0; arr.forEach(function (item, index) { item = Number(item); if (isNaN(item) === false) { total += item; } }); console.log(total); */ /* arr.forEach(function (item, index) { // 此函數會被循環執行五次(數組中有5項) // item:當前遍歷這一項的內容 // index:當前項的索引 console.log(item, index); }); */ // MAP支持返回值,但是不會改變原來的數組,執行完的返回結果是修改后的新數組 /* let arr = [10, 20, 30, 40, 50]; let result = arr.map(function (item, index) { // 數組中有5項,此函數被循環執行了5次 // item:當前循環這一次的值 // index:當前值對應的索引 // 函數中返回啥,都是把數組中當前項替換成啥 return item * 10; }); console.log(result); */ </script> ~~~ ![](https://img.kancloud.cn/72/24/72247f354efd30db57a35ba6cfd20eaf_572x223.png) ![](https://img.kancloud.cn/2d/06/2d061bc7bf7f77c4e88d41cf5f6c59d5_387x73.png) ![](https://img.kancloud.cn/47/b1/47b1d50a0da138331ef7e447b07caeb0_502x211.png) ![](https://img.kancloud.cn/66/97/6697660f7988ff87d9650e5f7346eeb8_1575x483.png) ![](https://img.kancloud.cn/59/a4/59a49c8760e1d8410cf565eab697bb34_1575x550.png) ![](https://img.kancloud.cn/f2/2b/f22bc553c1a100c9a1457711a9918b7f_1577x72.png) ![](https://img.kancloud.cn/65/c8/65c87aaaf7ba7262b4c38e3dedf6b0f4_1576x500.png) ![](https://img.kancloud.cn/2d/d0/2dd0be52c1f3d1c8f205e5a03a89e3c0_1578x212.png)
                  <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>

                              哎呀哎呀视频在线观看