function ArrayDiff(a, b){
        const setX = new Set(a)
        const setY = new Set(b)
      	
        return [
          ...a.filter(x=>!setY.has(x)),
          ...b.filter(x=>!setX.has(x))
        ]
      }
      const Array1 = [1, 2, 3];
      const Array2 = [1, 2, 3, 4, 5];
      console.log(ArrayDiff(Array1, Array2))
      
      Javascript language logo

      Difference in Arrays

      Find difference in array in JavaScript

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.