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

setEvery

Last update:
Jun 9, 2026
Returns true if callback(item) is true for all elements; vacuously true on an empty set.

Description

Used to determine if every element in an array satisfies a specific condition. It returns true if the callback function returns true for all elements, and false if any element fails the test.

Returns

Boolean.

Category

ColdFusion Set helper utilities

Function syntax

setEvery(set, callback)

Parameters

ParameterDescription
setSet to test.
callbackA closure or function executed for each item.

See also

Example

The following example uses this API in cfscript (syntax: utils.setEvery(set, callback)).

<cfscript>
    s = setNew();
    s.add(1);
    s.add(2);
    s.add(3);
    s.add(4);
    s.add(5);

    everySet=setEvery(s,function(element,index){
        return element > 2; // Check if all elements are greater than 2
    })
    writeOutput(everySet) // false (1 and 2 are not > 2)
</cfscript>
      

Real-world example

Before submitting a Set of distinct SKUs from a cart or import, ensure none are unknown.

<cfscript>
    cartSkus = setNew();
    cartSkus.add("SKU-100");
    cartSkus.add("SKU-200");
    cartSkus.add("SKU-999");

    approved = setNew();
    approved.add("SKU-100");
    approved.add("SKU-200");
    approved.add("SKU-300");

    allApproved = setEvery(cartSkus, function (sku) {
        return approved.has(sku);
    });

    writeOutput(allApproved); // false (SKU-999 not approved)
</cfscript>
      

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