Extending Native Array

I have not written code extending Array yet, as I have had concerns about breaking the web while extending Array. The problem is that any changes to the prototype of Array breaks "for … in" loops. After some discussion with other JavaScript architects and further thought, it became apparent that extending Array doesnt really break the web. First of all, the only issue is that after modifying the "Array.prototype", using "for … in" loops on an Array returns each attached Function, as well as each member of the Array, so you would have to do what YUI does and ignore theses keys. However, you would only need to use "for … in" loops if you were creating associative arrays, and an associative Array can be represented instead with an Object, so there is no need to use them. Therefore, it is good practice to use Object in place of any associative Arrays. If you follow this practice, then one only needs to iterate numerically on an Array, never needing the "for … in" loop; allowing us to safely extend "Array.prototype" with useful methods.

The most important method is probably the "Array.get" Function attached statically to Array. This method converts Array-like objects such as arguments and collection to an Array, so that you get all the syntactic sugar of "array.js" on non-arrays. This is most useful in conjunction with "document.getElementsByTagName" or simply arguments.

I have also added the concept of a pointer to Array so that you can iterate through the Array with functions like: next, prev, and current, which point to the appropriate index in the Array. Some other useful short-hand methods like: first and last have also been added.

Beyond those, there is a slew of other useful functions, that allow for easy Array management. It is all well documented, check "array.js" out here. And I have written an array unit test here.