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:
- Program:
<!DOCTYPE html><html><head><title>>>> Operator in JavaScript</title><style>body {text-align: center;}h1 {color: green;}</style></head><body><h1>GeeksforGeeks</h1><h3>The >>> Operator in JavaScript</h3><script>document.write("For non negative number:<br>");var a = 12;// Shift right two bitsvar b = 2;document.write("a = " + a + " , b = " + b);document.write("<br>a >>> b = " + (a >>> b) + '<br>');document.write("<br>For negative number:<br>");var a = -10;// Shift right two bitsvar b = 3;document.write("a = " + a + " , b = " + b);document.write("<br>a >>> b = " + (a >>> b) + '<br>');</script></body></html>chevron_rightfilter_none - Output:

Explanation: For non-negative numbers, zero-fill right shift (>>>) and sign-propagating right shift (>>) gives the same output. For example, 9 >>> 2 and 9 >> 2 gives same result i.e. 2. But for negative numbers, -9 >>> 2 gives 1073741821 and -9 >> 2 gives -3 as output.
Case 1: non-negative number
12 (base 10): 00000000000000000000000000001100 (base 2)
--------------------------------
12 >>> 2 (base 10): 00000000000000000000000000000011 (base 2)
= 3 (base 10)
Case 2: negative number
-10 (base 10): 11111111111111111111111111110110 (base 2)
--------------------------------
-10 >>> 3 (base 10): 00011111111111111111111111111110 (base 2)
= 536870910 (base 10)
Recommended Posts:
- JavaScript TypeError - Cannot use 'in' operator to search for 'X' in 'Y'
- Why overriding both the global new operator and the class-specific operator is not ambiguous?
- Ternary operator vs Null coalescing operator in PHP
- JavaScript Course | Conditional Operator in JavaScript
- How to use map and filter simultaneously on an array using JavaScript ?
- How to use Selenium Web Driver and JavaScript to Login any website ?
- Difference between == and === operator in JavaScript
- Difference between != and !== operator in JavaScript
- Must use JavaScript Array Functions – Part 3
- When to use PreventDefault( ) vs Return false in JavaScript?
- How to use loop through an array in JavaScript?
- How to use Regex to get the string between curly braces using JavaScript ?
- How to use goto in Javascript ?
- How to use a variable for a key in a JavaScript object literal?
- When to use Vanilla JavaScript vs jQuery ?
- How to use dynamic variable names in JavaScript ?
- How to use map() on an array in reverse order with JavaScript ?
- How to use JavaScript variables in jQuery selectors ?
- How to Use the JavaScript Fetch API to Get Data?
- How to use javascript function in check box?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


