<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智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [toc] #### 1. 展開語法`...` #### 2. join方法 將數組拼接成字符串 ``` var arr = ["green", "yellow", "red"]; var str = arr.join("."); console.log(str); ``` #### 3. 排序 升序: ``` var arr = [1, 3, 4, 2, 9, 5]; var d = arr.sort(function(a, b){ return a-b; }) console.log(d); //升序 ``` 降序: ``` var f = arr.sort(function(a, b){ return b-a; }) console.log(f); //降序 ``` #### 4. 求和 ``` var arr = [1, 2, 3, 4]; var sum = arr.reduce((a,b)=>a+b); console.log(sum); /* var sum = arr.reduce(function(a, b){ return a+b; }) */ ``` #### 5. 顛倒 ``` let arr = [1, 2, 3, 4]; arr.reverse(); console.log(arr); //4, 3, 2, 1 ``` #### 6. 獲取數組最大值 ``` 1. var max = Math.max(...arr); 2. var max = Math.max.apply(null, arr); 3. 在原型上定義方法: Array.prototype.max = function(arr) { return Math.max(...arr); } console.log(arr.max(arr)); ``` #### 附:數組新增的方法 ``` 注意: forEach some filter findIndex 都屬于數組的新方法 forEach 無法中止,完整遍歷一遍 some 可以用return ture終止 filter 查詢 findIndex 查詢index值 ,執行回調函數查詢 都會對數組中的每一項,進行遍歷,執行相關操作 ``` >#### 附:將類數組對象強制轉換為數組遍歷 強制轉換為數組:`Array.prototype.slice.call(obj)` 遍歷方法:`arr.forEach(function(item, index){})` ``` // 點擊li標簽變色 var childs = document.getElementById("parent").children; var arr = Array.prototype.slice.call(childs); arr.forEach(function(item, index){ item.onclick = function(){ // console.log(this); // arr.forEach(function(item, index){ // item.style.color = "#000"; // }) arr.forEach((item, index)=>{ item.style.color = "#000"; }) this.style.color = "red" } }) ```
                  <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>

                              哎呀哎呀视频在线观看