What is the JavaScript >>> operator and how do you use it?

后端 未结 7 2235
野性不改
野性不改 2020-11-22 02:41

I was looking at code from Mozilla that add a filter method to Array and it had a line of code that confused me.

var len = this.length >>> 0;
         


        
7条回答
  •  半阙折子戏
    2020-11-22 03:32

    That is the unsigned right bit shift operator. The difference between this and the signed right bit shift operator, is that the unsigned right bit shift operator (>>>) fills with zeroes from the left, and the signed right bit shift operator (>>) fills with the sign bit, thus preserving the sign of the numerical value when shifted.

提交回复
热议问题