What does the notation somevar >> 0
mean in javascript?
Thanks
Bitwise right shift. Although somevar >> 0
looks weird.
In a >> b
, >>
is a bitwise operator that shifts a
in binary representation b
(< 32) bits to the right, discarding bits shifted off.
Reference: https://developer.mozilla.org/en/JavaScript/Reference/Operators/Bitwise_Operators
It's a bitwise operator. In this case, for shifting the first operand in binary representation the number of bits to the right specified in the second operand, discarding bits shifted off.
With a 0
as second operand, I guess it has no effect (shifting 0 bits, is getting the same value?).
I was wrong with this last. As explained at this @Gumbo's comment.