0

I just stumbled upon a bit of code that I can't find anything about:

function solution(A) {

    var agg = 0;

    for(var i=0; i<A.length; i++) {
        agg ^= A[i];
    }

    return agg;
}

What does the ^= operator do? This code is the solution to a problem on Codility.

gkpo
  • 2,093
  • 2
  • 22
  • 36
  • It's an xor assignment. – Jonas Wilms Apr 27 '20 at 19:57
  • Much like `x += y` is a short way to write `x = x + y`, `x ^= y` is a short way to write `x = x ^ y`. You can find `^` in the list that this question was linked to now, it's a bitwise XOR. – CherryDT Apr 27 '20 at 20:01

0 Answers0