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])) → returns array

Member Function Syntax [,index, array]))

arrayMap Argument Reference

array array

The input array

callback function

Closure or a function reference that will be called for each of the iteration. The arguments passed to the callback are

item: item in the array
index: index of the 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

Examples 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]

Fork me on GitHub