views:

50

answers:

0

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

Mozilla's Array.prototype.map(), described in the Javascript 1.5 documentation, is implemented with the following:

if (!Array.prototype.map)
{
  Array.prototype.map = function(fun /*, thisp*/)
  {
    var len = this.length >>> 0;
    if (typeof fun != "function")
      throw new TypeError();

    var res = new Array(len);
    var thisp = arguments[1];
    for (var i = 0; i < len; i++)
    {
      if (i in this)
        res[i] = fun.call(thisp, this[i], i, this);
    }

    return res;
  };
}

The line I'm struggling to understand is:

var len = this.length >>> 0;

Mozilla's Js 1.5 bit-wise operator reference, explains that >>> is the bitwise operator Zero-fill right shift.

Zero-fill right shift

Shifts a in binary representation b (< 32) bits to the right, discarding bits shifted off, and shifting in zeros from the left.

Does this provide some kind of safety that returning array.length does not, or is this some kind of type coercion?