<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] >[success] # 兩數組的差集 -- 總結 ~~~ 1.獲取交集,即過濾出AB 兩數組中只有A特有的元素 ~~~ >[info] ## 解決思路 ~~~ 1.使用filter set 和has作為條件,只要沒有的即為差集 2.使用filter 和 some,some false表示沒有一個相同,沒有一個相同的就是差集 3.使用filter 和 indexOf 判斷這個值是否存在 4. ~~~ >[danger] ##### set 和 has 作為條件 ~~~ const difference = (a,b)=>{ const sA = new Set(a); const sB = new Set(b); return [...sA].filter((v)=>!sB.has(v)) } console.log(difference([1, 2, 3], [1, 2, 4])) // [ 3 ] ~~~ >[danger] ##### filter 和 some ~~~ const difference1 = (a,b)=>{ // 都是一個系列some 換成includes indexOf return [...new Set(a.filter(v=>!b.some(val=>val===v)))] } console.log(difference1([1, 2, 3], [1, 2, 4])) // [ 3 ] ~~~ >[danger] ##### 過濾對象系列 * some ~~~ const difference1 = (a,b,fn)=>{ // 都是一個系列some 換成includes indexOf return [...new Set(a.filter(v=>!b.some(val=>fn(v,val))))] } console.log(difference1([{id:'1'},{id:'2'}], [{id:3}],(v,v1)=>v.id === v1.id)) // [ { id: '1' }, { id: '2' } ] ~~~ * findIndex ~~~ const differenceWith = (arr,val,com= (a,b)=>a===b) => arr.filter(a=>val.findIndex((b)=>com(a,b)) ===-1) log(differenceWith( [1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Math.round(b) )) // [1, 1.2] log(differenceWith([1, 1.2, 1.3], [1, 1.3, 1.5])) // [1.2] ~~~
                  <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>

                              哎呀哎呀视频在线观看