此问题在此处已有答案:
How to compare two arrays and then return the index of the difference?(4个答案)
How to get the difference between two arrays in JavaScript?(83个答案)
Javascript compare 2 arrays index by index, and not by total number of values the 2 arrays have in common(2个答案)
4天前关闭。
var a=["a","b","c","d"];
var b=["b","a","c","d"];
我需要的输出如下:
不匹配的数组
不匹配数组= ["a", "b"];
2条答案
按热度按时间lymnna711#
您可以使用筛选函数并检查两个数组中索引的值,然后从中获取不匹配的值。
wgx48brx2#
这里我使用Javascript的filter方法来获取不匹配的Array。