arrayEvery

returns true if every closure returns true, otherwise false

arrayEvery(array array, function(item, [index, [array]]) closure, [boolean parallel], [number maxThreads]) → returns boolean

Member Function Syntax

someArray.every(function(item, [index, [array]]) closure, [boolean parallel], [number maxThreads])

Argument Reference

array array
Required

closure function
Required

A function / closure with the signature: boolean function (any item, [numeric index], [array array])

parallel boolean
Default: false

Lucee 4.5+ When true the items can be executed in parallel

maxThreads boolean
Default: 20

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

Links more information about arrayEvery

Examples
Sample code invoking the arrayEvery function

Checks whether all items in an array are greater than 2 and outputs true because all of them fulfill the requirement.

array = [4, 5, 6, 7];
writeOutput(arrayEvery(array, function(value) { return value gt 2; }));

Expected Result: true

Checks whether all items in an array are greater than 2 and outputs false because some of them do not fulfill the requirement.

array = [1, 2, 3, 4];
writeOutput(arrayEvery(array, function(value) { return value gt 2; }));

Expected Result: false

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

Fork me on GitHub