📜  从两个数组 js 中返回不常见的 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:08.551000             🧑  作者: Mango

代码示例2
let array = [1,2,3,4,5,6,78,9];

function except(array,excluded){
let newArr,temp,temp1;

      check1=array.filter(function(value) 
                {
                  return excluded.indexOf(value) == -1; 

                });

      check2=excluded.filter(function(value) 
                {
                  return array.indexOf(value) == -1; 

                });

    output=check1.concat(check2);


    return output;

  }


except(array,[1,2])

//so the output would be => [ 3, 4, 5, 6, 78, 9 ]