const symmetricDifference = (a: Array<number>, b: Array<number>) => {
        const sA: Set<number> = new Set(a),
          sB: Set<number> = new Set(b);
        return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))];
      };
      
      Typescript language logo

      Symmetric Difference

      0

      0

      avatar
      Giovanny Gongora
      Codiga's TypeScript Recipes

      Returns the symmetric difference between two arrays, without filtering out duplicate values.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.