Purpose of >> 0 and >>> 0

前端 未结 2 1410
广开言路
广开言路 2021-01-03 05:48

This sample code from Mozilla\'s JS reference uses the >> and >>> operators with a RHS argument of 0. I guess this is an alternative to Math.floor() that has a performance a

2条回答
  •  长情又很酷
    2021-01-03 06:35

    It converts them to numbers that can be expressed as 32-bit unsigned ints. So yes it will make it a (typeof number) as a floored int, it will also make it a 32-bit unsigned, which JS programming loves :)

    The main difference is the signed vs unsigned.

提交回复
热议问题