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);
}
}
};
-
Mikhail Korobov commented
How is that related to MooTools Forge?