What's the best way to find intersection in 2 arrays and what algorithmic complexity does each of the ways have?

后端 未结 0 536
忘掉有多难
忘掉有多难 2021-01-02 18:47

1)with some

function test(arr1,arr2){
  return arr1.filter(el1=>{
    return arr2.some(el2=>{
      return el2 === el1
    })
  })
}

co

相关标签:
回答
  • 消灭零回复
提交回复
热议问题