What is JavaScript >>> Operator and How to use it ?

The JavaScript >>> represents zero-fill right shift operator. It is also called the unsigned right bit shift operator. It comes under the category of Bitwise operators. Bitwise operators treat operands as 32-bit integer numbers and operate on their binary representation.

Zero-fill right shift (>>>) operator:
It is a binary operator, where the first operand specifies the number and the second operand specifies the number of bits to shift. The operator shifts the bits of the first operand by a number of bits specified by the second operand. The bits are shifted to the right and those excess bits are discarded, while 0 bit is added from left. As the sign bit becomes 0, the operator ( >>> ) returns a 32-bit non-negative integer.

Example:

Input:
A = 6 ( 00000000000000000000000000000110 )
B = 1 ( 00000000000000000000000000000001 )

Output:
A >>> B = 3 ( 00000000000000000000000000000011 )

Syntax:

result = expression1 >>> expression2

Difference between >>> and >> :
The difference between these two is that the unsigned zero-fill right shift operator (>>>) fills with zeroes from the left, and the signed right bit shift operator (>>) fills with the sign bit from the left, thus it maintains the sign of the integer value when shifted.



Example: This example implements the use of >>> operator: