vue 两个数组判断是否有重复,有几种判断方式?
let arr1 = ['runoob', 'google']
let arr2 = ['jingdong', 'google', 'taobao']
vue 两个数组判断是否有重复,有几种判断方式?
let arr1 = ['runoob', 'google']
let arr2 = ['jingdong', 'google', 'taobao']
随便写两种
let arr1 = ['runoob', 'google']
let arr2 = ['jingdong', 'google', 'taobao']
//
console.log(arr1.some(r => arr2.includes(r)))
//
console.log(!arr1.every(r => !arr2.includes(r)))
//
console.log(arr1.filter(r => arr2.includes(r)).length)
10 回答11.3k 阅读
5 回答4.9k 阅读✓ 已解决
4 回答3.2k 阅读✓ 已解决
2 回答2.8k 阅读✓ 已解决
2 回答4.8k 阅读✓ 已解决
4 回答4.4k 阅读✓ 已解决
4 回答1.9k 阅读✓ 已解决