What does “somevar >> 0” mean?

前端 未结 3 734
野趣味
野趣味 2020-11-28 15:30


What does the notation somevar >> 0 mean in javascript?

Thanks

相关标签:
3条回答
  • 2020-11-28 15:57

    Bitwise right shift. Although somevar >> 0 looks weird.

    0 讨论(0)
  • 2020-11-28 16:06

    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

    0 讨论(0)
  • 2020-11-28 16:09

    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.

    0 讨论(0)
提交回复
热议问题