Iterates over every entry of the array and calls the closure function to work on the element of the array. The returned value will be set at the same index in a new array and the new array will be returned

arrayMap(array, function(item [,index, array]){} [, parallel] [, maxThreads]) → returns array

Member Function Syntax [,index, array]){} [, parallel] [, maxThreads])

Argument Reference

array array

The input array

callback any

Closure or a function reference that will be called for each of the iteration.

Callback parameters:

  • value*any : The value for the current iteration
  • index*numeric : The current index for the iteration
  • array*array : A reference of the original array

parallel boolean
Default: false

Lucee 4.5+ true if the items can be executed in parallel
  • true
  • false

maxThreads numeric
Default: 20

Lucee 4.5+ the maximum number of threads to use when parallel = true

Links more information about arrayMap

Sample code invoking the arrayMap function

complexData = [ {a: 4}, {a: 18}, {a: 51} ];
newArray = arrayMap( complexData, function(item){
   return item.a;

Expected Result: [4, 18, 51]

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub