arrayEach

Used to iterate over an array and run the function closure for each item in the array.

arrayEach(array, function(item, [index, [array]]), [parallel], [maxThreads]) → returns void

Member Function Syntax

someArray.each(function(item, [index, [array]]), [parallel], [maxThreads])

arrayEach Argument Reference

array array
Required

callback function
Required

function / closure with the signature: any function (any item, [numeric index], [array array]) - will be executed once per item in the array

parallel boolean
Default: false

Lucee 4.5+ Specifies whether the items can be executed in parallel

maxThreads numeric
Default: 20

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

Links more information about arrayEach

Examples sample code invoking the arrayEach function

letters = ["a","b","c","d"]; 
arrayEach(letters, function(element,index) {
    writeOutput("#index#:#element#;");
});

Expected Result: 1:a;2:b;3:c;4:d;

a = ["a","b","c"];
a.each(function(element,index,array){
    writeOutput("#index#:#element#;"); 
});

Expected Result: 1:a;2:b;3:c;


Fork me on GitHub