Used to filter an list to items for which the closure function returns true.
listFilter(list, function(listElement, [list]) )
returns string
someList.listFilter(function(listElement, [list]) )
Name | Type | Required | Default | Description |
---|---|---|---|---|
list | string | Yes | ||
function | function | Yes | Inline closure function executed for each element in the list. Returns true if the list element should be included in the filtered list. Support for passing the original list to the closure function added in CF11 Update 5. |
Take list and use List Filter to return items that are 3 and higher.
numberList = '1,2,3,4,5,6';
threeOrMore = listFilter(numberList, function(item){
return item >= 3;
});
writedump(threeOrMore);
This is the same example as above, but using a member function on the list instead of a standalone function.
numberList = '1,2,3,4,5,6';
threeOrMore = numberList.listFilter(function(item){
return item >= 3;
});
writedump(threeOrMore);