ArrayFilter()
Used to loop over the array to create a new array based on the inner function applied to each element that will return true/false if it is to be included
Usage
ARRAY = ArrayFilter(
array,
function
)
Argument | Summary |
---|---|
array | Array Object |
function | function to loop over the data, passing in the element as the parameter to each. each function call should return true or false; function(element){} |
Calling
Supports named-parameter calling allowing you to use the function like:
ArrayFilter( array=?, function=? );
Supports passing parameters as a structure using ArgumentCollection:
ArrayFilter( ArgumentCollection={ array : ?, function : ? } );
Extra
Creates a brand new array using the elements from the previous one, by using a callback function to determine whether or not the element should be included. The callback function must return either true/false.
<cfscript> // Create a sample array arr = ["alan", "ceri", "andy", "jamie" ]; // Callback function declared that accepts the element function arrayLoopCallback(el){ if ( el.startsWith("a") ) return true; else return false; } // Create a new array from the old one newArr = ArrayFilter( arr, arrayLoopCallback ); </cfscript>
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