x >>> 0
performs a logical (unsigned) right-shift of 0 bits, which is equivalent to a no-op. However, before the right shift, it must convert the x
to an unsigned 32-bit integer. Therefore, the overall effect of x >>> 0
is convert x
into a 32-bit unsigned integer.
This ensures len
is a nonnegative number.
js> 9 >>> 0
9
js> "9" >>> 0
9
js> "95hi" >>> 0
0
js> 3.6 >>> 0
3
js> true >>> 0
1
js> (-4) >>> 0
4294967292