话不多说 直接上干货内联代码片

// 数组A
let arrA = ['1111','2222','333','4444','5555']
// 数组B
let arrB= ['aaa','bbb','4444','5555','dddd','eeee','ffff','yyyy','mmmm']
过滤B数组中不包含A数组的项
let differentArr = arrB.filter(item => arrA.indexOf(item) > -1)
// differentArr =['aaa','bbb','dddd','eeee','ffff','yyyy','mmmm']
过滤B数组中包含A数组的项
let differentArr = arrB.filter(item => arrA.indexOf(item) != -1)
// differentArr =['4444','5555']

Logo

前往低代码交流专区

更多推荐