Sunday, October 26, 2008

Array Functions in AS3

AS3 Array class has some really handy functions that I never noticed before. They will be very useful (how did I ever NOT notice them?):

every(callback:Function, thisObject:* = null):Boolean
Executes a test function on each item in the array until an item is reached that returns false for the specified function.

filter(callback:Function, thisObject:* = null):Array
Executes a test function on each item in the array and constructs a new array for all items that return true for the specified function.

forEach(callback:Function, thisObject:* = null):void
Executes a function on each item in the array.

map(callback:Function, thisObject:* = null):Array
Executes a function on each item in an array, and constructs a new array of items corresponding to the results of the function on each item in the original array.

some(callback:Function, thisObject:* = null):Boolean
Executes a test function on each item in the array until an item is reached that returns true.