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

后端 未结 7 2088
野性不改
野性不改 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:21

    Sample Java Code below explains well:

    int x = 64;
    
    System.out.println("x >>> 3 = "  + (x >>> 3));
    System.out.println("x >> 3 = "  + (x >> 3));
    System.out.println(Integer.toBinaryString(x >>> 3));
    System.out.println(Integer.toBinaryString(x >> 3));
    

    Output is the following:

    x >>> 3 = 536870904
    x >> 3 = -8
    11111111111111111111111111000
    11111111111111111111111111111000
    

提交回复
热议问题