What does>> = mean?

I don’t understand what → = means (I thought it was greater than or equal to> =) and what is: (times and 1) below.

function repeat (string, times) {
var result = ''
while (times > 0) {
if (times & 1) result += string
times >>= 1
string += string
}
 return result
}
+4
source share
1 answer

>>=- this is the right shift and appointment see . >>= 1- just a whole division by 2.

&- Bitwise And see . time & 1just checks if it is odd.

A more detailed guide to all javascript statements is here: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators

+5
source

All Articles