Symmetric Difference

Find elements in either array but not in both (exclusive OR).

Code

General
const setA = new Set(arr1), setB = new Set(arr2);
return [...arr1.filter(x => !setB.has(x)), ...arr2.filter(x => !setA.has(x))];

Parameters

First array

Second array

Browser·fetch() may be limited by CORS

More JavaScript Snippets