There are times you may ask yourself "Why isn't that part of MooTools?" and while there are possibly a lot of answers to that it simply could be that it is something with only small usage.
For that reason MooTools made it easy for you to extend any native object like Arrays, Strings etc. to add the functionality you want.
In this example you will learn how to extend the Array-Object with a custom function. For this we create an Array with Fx.Tween instances and start the effect on all Array elements. You may need to have a look at the source of this demo.
Execute ExampleArray.implement({ invoke: function(fn, args){ var result = []; for (var i = 0, l = this.length; i < l; i++){ if(this[i] && this[i][fn]) result.push(args ? this[i][fn].pass(args, this[i])() : this[i][fn]()); } return result; } });
myArray.invoke('fn', args);