我想检查 2 个数组中的重叠值
场景一:
cuisineA = [a,b,c];
cuisineB = [a,b,c,d,e,f];
将返回一个布尔值isOverlap = true
场景2:
cuisineA = [a,b,c];
cuisineB = [d,e,f];
将返回一个布尔值isOverlap = false
目前我的代码看起来像这样
const overlapCuisines = this.cuisineA.filter(
cuisine => this.cuisineB.indexOf(cuisine) < 0
);
this.isOverlap = overlapCuisines.length > 0;
然而,当它在场景 2 中时,overlapCuisines 将包含值 [a,b,c],因此 isOverlap = true 当它应该是 false 时。我应该如何编码以正确显示它?感谢你的帮助!
饮歌长啸
侃侃无极
哈士奇WWW
相关分类