Description

Used to filter the elements of an array.

Returns

A new array

Category

Closure functions

Syntax

arrayFilter(array,function(arrayElement){return true|false;});

Example

<cfscript>
names = ["Ray","Adam","Scott","Todd","Dave"];
shortNames = arrayFilter(names, function(n) {
return len(n) < 4;
});
writeDump(shortNames);
</cfscript>

See also

Other closure functions.

History

ColdFusion 10: Added this function.

Parameters

Parameter

Description

array

Name of the array object.

function

Inline function executed for each element in the array. Returns true if the array element has to be included in the resultant array.

arrayElement

Array element being accessed.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy