55

I just came across this piece in the Mozilla Javascript documentation:

var len = this.length >>> 0;  

I don't quite understand why this is being done. What good does zero-fill right shifting this.length by 0 do? As far as I understand, it does exactly nothing. Is it to safely establish a default value for len, even if this.length is not an integer? Can this ever feasibly be the case? If so, what's the difference between >> 0 and >>> 0?

deceze
  • 491,798
  • 79
  • 706
  • 853

0 Answers0