Wednesday, July 3, 2024
HomeLanguagesJavascriptRight Shift Assignment(>>=) Operator in JavaScript

Right Shift Assignment(>>=) Operator in JavaScript

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; // 00000000000000000000000000000111
  
x >>= 2;   // 00000000000000000000000000000001
  
console.log(x);


Output

1

Example 2: In this example, we will see assigning the right shift operator to the variable.

Javascript




let a = 10; // 00000000000000000000000000001010
let b = 2;  // 00000000000000000000000000000010
a = a >> b; // 00000000000000000000000000000010
  
console.log(a);


Output

2

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
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!

Shaida Kate Naidoo
am passionate about learning the latest technologies available to developers in either a Front End or Back End capacity. I enjoy creating applications that are well designed and responsive, in addition to being user friendly. I thrive in fast paced environments. With a diverse educational and work experience background, I excel at collaborating with teams both local and international. A versatile developer with interests in Software Development and Software Engineering. I consider myself to be adaptable and a self motivated learner. I am interested in new programming technologies, and continuous self improvement.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments