The symmetric difference of several arrays is the set of values that belong to exactly one of them — everything except the values they share. It is the array-level version of XOR, the "one or the other, but not both" operation, and lodash exposes it as _.xor. You keep the loners and drop anything that shows up in more than one list.
Implement arrayXor(...arrays) that takes any number of arrays and returns a new array of the values appearing in exactly one input array. Duplicates are removed, and the surviving values stay in the order they first appear across the inputs.
function arrayXor(...arrays) {
// returns the values that appear in exactly one of the given arrays
}
arrayXor([2, 1], [2, 3]);
// → [1, 3] // 2 is in both arrays, so it drops out
arrayXor([1, 2], [4, 2], [2, 3]);
// → [1, 4, 3] // 2 appears in all three, so it is excluded
arrayXor([1, 1, 2], [2]);
// → [1] // duplicates inside one array collapse; 2 is shared
[1, 1] contributes the value 1 a single time.SameValueZero — the rule Set and Array.includes use. NaN equals NaN, and 0 equals -0. The number 1 and the string '1' are different values.arrayXor() returns []; a single array returns its unique values.