sstephenson/prototype — comment on commit 460be4691af9e4e92908c9ac707597bad69be57c
File: src/prototype/lang/array.js line 517
By savetheclocktower:

Keith, this piece of code does `object.length >>> 0` because it's exactly what [ToUInt32](http://es5.github.com/#x9.6) does. This expression just happens to map exactly to an internal operation of the ES5 spec.

For array methods like `map` and `filter` and whatnot, the spec has us read the `length` property, do a ToUInt32 operation, and treat that as the length of the object. These methods have to work generically — I should be able to do this and have it work:

``` javascript

var obj = { 0: 'a', 1: 'b', 2: 'c', length: '3' };
[].map.call(obj, function(i) { return i; });

//-> ["a", "b", "c"]
```
Replace that length value with `true` and it'll loop just once (`true` gets coerced to `1`), or replace it with `-1` and crash your browser (`-1` gets coerced to `4294967295`). So, yeah, ToUInt32 behaves _interestingly_ in some ways, but it's exactly what the spec instructs us to do, so there you have it.