# Array.js

Contains Array prototypes and the function $A;

#### Dependencies

Moo.js

#### Author

Valerio Proietti, http://mad4milk.net

#### License

MIT-style license.

Summary

Array.js | Contains Array prototypes and the function $A;
Array | A collection of The Array Object prototype methods.
Properties |
each | Same as Array.each.
copy | Copy the array and returns it.
remove | Removes an item from the array.
test | Tests an array for the presence of an item.
extend | Extends an array with another
associate | Creates an associative array based on the array of keywords passed in.
Utility Functions |
Functions |
$A() | Same as Array.copy, but as function.

## Array

A collection of The Array Object prototype methods.

Summary

Properties |
each | Same as Array.each.
copy | Copy the array and returns it.
remove | Removes an item from the array.
test | Tests an array for the presence of an item.
extend | Extends an array with another
associate | Creates an associative array based on the array of keywords passed in.

### Properties

### each

Same as Array.each.

### copy

Copy the array and returns it.

#### Returns

an Array

#### Example

>     var letters = ["a","b","c"];
>     var copy = ["a","b","c"].copy();

### remove

Removes an item from the array.

#### Arguments

item | the item to remove

#### Returns

the Array without the item removed.

#### Example

>     ["1","2","3"].remove("2") // ["1","3"];

### test

Tests an array for the presence of an item.

#### Arguments

item | the item to search for in the array.

#### Returns

true | the item was found
false | it wasn’t

#### Example

>     ["a","b","c"].test("a"); // true
>     ["a","b","c"].test("d"); // false

### extend

Extends an array with another

#### Arguments

newArray | the array to extend ours with

#### Example

>     var Animals = ['Cat', 'Dog', 'Coala'];
>     Animals.extend(['Lizard']);
>     //Animals is now: ['Cat', 'Dog', 'Coala', 'Lizard'];

### associate

Creates an associative array based on the array of keywords passed in.

#### Arguments

keys | the array of keywords.

#### Example

(sart code) var Animals = [‘Cat’, ‘Dog’, ‘Coala’, ‘Lizard’]; var Speech = [‘Miao’, ‘Bau’, ‘Fruuu’, ‘Mute’]; var Speeches = Animals.associate(speech); //Speeches[‘Miao’] is now Cat. //Speeches[‘Bau’] is now Dog. //... (end)

## Utility Functions

Summary

Functions |
$A() | Same as Array.copy, but as function.

### Functions

### $A()

> function $A( | array | )

Same as Array.copy, but as function. Useful to apply Array prototypes to iterable objects, as a collection of DOM elements or the arguments object.

#### Example

>     function myFunction(){
>        $A(arguments).each(argument, function(){
>            alert(argument);
>        });
>     };
>     //the above will alert all the arguments passed to the function myFunction.

> function $A( | array | )

Copy the array and returns it.
Same as Array.copy, but as function.
Same as <Array.each>.
My Object Oriented javascript.