I thought Math.pow(2,2) is 2^2 , but that is not the case. So what does ^ (caret) mean in JavaScript?
Math.pow(2,2)
2^2
^
I ran some tests in the console but did not recognize the results:
2 ^ 2 = 0 2 ^ 3 = 1 1 ^ 2 = 3
This means bitwise XOR .
This is a bitwise integer XOR operation ( MDC reference ).
Operator ^ bitwise XOR, you have more information in MDN: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Bitwise_Operators
This statement performs a logical XOR operation. (the out bit is 1 when both input bits are different).
This is a bitwise XOR operator that returns one for each position, where one (not both) of the corresponding bits of its operands is one. The following example returns 4 (0100):
Code: result = a ^ b;