I found out recently that you can use this function on an array of integers to find the one number that appears an odd number of times using JavaScript.
array.reduce((a, b) => a ^ b);
[1, 2, 2].reduce((a, b) => a ^ b); // returns 1
I'm struggling to figure out how the XOR operation (^) works and am wondering if there is a similar function that can find a number that appears an even number of times in an array.