I came across some code as noted below and am confused as to what it's doing.
hash += (hash << 10);
I came across some code as noted below and am confused as to what it's doing.
hash += (hash << 10);
It's a Bitwise Operator.
Here's an example from the MDN (linked to above):
9 (base 10): 00000000000000000000000000001001 (base 2)
--------------------------------
9 << 2 (base 10): 00000000000000000000000000100100 (base 2) = 36 (base 10)
See how the 1s have shifted?
This is one of the JavaScript bitwise operators:
Left Shift
a << b
Shifts a in binary representation b (< 32) bits to the left, shifting in zeros from the right.