Whatever message this page gives is out now! Go check it out!

ListMap

Last update:
May 18, 2026
Description
Iterates over every entry of the list and calls the closure function to work on the item of the list. The returned value will be set at the same index in a new list and the new list will be returned.

Returns

List

Syntax

ListMap(list, callback [,delimiter, includeEmptyFields])
History
ColdFusion (2018 release): Introduced named parameters.
ColdFusion 11: Added this function.

Parameters

Parameter
Req/Opt
Default
Description
list
Required
The input list.
callback
Required
Closure or a function reference that will be called for each iteration. The arguments passed to the callback are
  • item: value
  • index: current index for the iteration
  • list: reference  of  the original list
  • delimiter: the list delimiter
  • includeEmptyFields: include empty values.
delimiter
Optional
comma (,)
The list delimiter. The type is  string .
includeEmptyFields
Optional
false
Include empty values. The type is boolean.

Example

<cfscript>
       myList="Tokyo,Bangkok,Jakarta,Manila,Bangalore,Shanghai";
       closure=function(item){ 
             return reverse(item); // Reverses each list item
             }
       myMap=ListMap(myList,closure);
       WriteOutput(myMap);
</cfscript>
Output
oykoT,kokgnaB,atrakaJ,alinaM,erolagnaB,iahgnahS

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page