ArrayEach()
Applies the function to each of the elements in the array
Usage
BOOLEAN = ArrayEach(
array,
function
)
Argument | Summary |
---|---|
array | Array Object |
function | function to loop over the data, passing in the element as the parameter to each. function(el){} |
Calling
Supports named-parameter calling allowing you to use the function like:
ArrayEach( array=?, function=? );
Supports passing parameters as a structure using ArgumentCollection:
ArrayEach( ArgumentCollection={ array : ?, function : ? } );
Extra
You can easily iterate over the elements of an array by using the ArrayEach() function or the .each() feature.
<cfscript> // Create a sample array arr = ["alan", "ceri", "andy", "jamie" ]; // Callback function declared that accepts the element function arrayLoop(el){ WriteDump( el ); } // Loop around each element ArrayEach( arr, arrayLoop ); // Alternatively you can loop using the .each() arr.each( arrayLoop ); </cfscript>
For each element in the array, the function 'arrayLoop' is called, passing in the current element. The callback function sits within the variable scope of the calling function, so it can interact with variables outside of itself.
See Also
ArrayAppend
ArrayAvg
ArrayClear
ArrayConcat
ArrayContains
ArrayContainsnocase
ArrayDeleteat
ArrayEach
ArrayFilter
ArrayFind
ArrayFindall
ArrayFindnocase
ArrayFirst
ArrayGet
ArrayIndexexists
ArrayInsertat
ArrayIsdefined
ArrayIsempty
ArrayLast
ArrayLen
ArrayMax
ArrayMin
ArrayNew
ArrayPrepend
ArrayResize
ArrayRest
ArrayReverse
ArraySet
ArraySlice
ArraySort
ArraySum
ArraySwap
ArrayTolist
ArrayTrim
ArrayTrimvalue
ArrayValuecount
ArrayValuecountnocase
Datasourceactivepoolstats
Newarray