modifying Array.each method
reviewing such libraries as jQuery and protovis I found out that they contain several useful tricks.
Array.prototype.each = function (fn, bind) {
var ret;
for (var i=0, n=this.length; i<n && ret !== false; i++) {
// Test for existance: i in this
// because if a user calls delete(array[index]) index is still in range
// but array[index] becomes undefined => we need to test
if (i in this) {
// if function returns false, break the iteration
ret = fn.call(bind, this[i], i, this);
}
}
};
![](https://secure.gravatar.com/avatar/4cd7e5fbd1780056d634895221a09c90?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
-
Mikhail Korobov commented
How is that related to MooTools Forge?