Javascript algorithm to find elements in array that are not in another array

前端 未结 8 1083
情歌与酒
情歌与酒 2020-11-27 06:19

I\'m looking for a good algorithm to get all the elements in one array that are not elements in another array. So given these arrays:

var x = [\"a\",\"b\",\         


        
8条回答
  •  北海茫月
    2020-11-27 06:52

     findDiff = (A, B) => {
         return  A.filter(function (a) {
              return !B.includes(a);
         });
     }
    

提交回复
热议问题