Description

Used to filter the elements of an array.

Returns

A new array

Category

Syntax

arrayFilter(array,filter)

See also

Other array functions.

History

ColdFusion (2018 release): Introduced named parameters.

ColdFusion 10: Added this function.

Parameters

Parameter

Description

array

Name of the array object.

filter

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

Example

<cfscript>
     superheroes=[
           {"name":"Iron Man","member":"Avengers"},
           {"name":"Wonder Woman","member":"Justice League"},
           {"name":"Hulk","member":"Avengers"},
           {"name":"Thor","member":"Avengers"},
           {"name":"Aquaman","member":"Justice League"}
     ];

     avengers=ArrayFilter(superheroes,function(item){
           return item.member=="Avengers";
     });
     writeDump(avengers);
</cfscript>

Output

ArrayFilter

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