Right Shift Assignment(>>=) Operator in JavaScript
Last Updated :
16 Mar, 2023
The Right Shift Assignment Operator is represented by “>>=”. This operator shifts the first operand to the right and assigns the result to the variable. It can also be explained as shifting the first operand to the right in a specified amount of bits which is the second operand integer and then assigning the result to the first operand.
Syntax:
a >>= b
Or
a = a >> b
Where –
- a is the first operand, and
- b is the second operand.
Example 1: In this example, we will see the implementation of the right shift assignment.
Javascript
let x = 7;
x >>= 2;
console.log(x);
|
Example 2: In this example, we will see assigning the right shift operator to the variable.
Javascript
let a = 10;
let b = 2;
a = a >> b;
console.log(a);
|
We have a complete list of Javascript Assignment Operators, Please check this article Javascript Assignment Operator.
Supported Browser:
- Chrome 1
- Edge 12
- Firefox 1
- Opera 3
- Safari 1
Share your thoughts in the comments
Please Login to comment...