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

isSubsetOf

Last update:
Jun 9, 2026
Returns true if every element of this set is in the other set.

Description

Returns true if every element of this set is also contained in the other set (this set is a subset of `other`: (A is a subset of B). For the empty set, subset semantics typically follow mathematical convention (empty set is subset of any set).

Returns

Boolean.

Category

ColdFusion Set member methods

Function syntax

set.isSubsetOf(otherSet)

Parameters

ParameterDescription
otherSetPotential superset.

See also

Example

The following example uses this API in cfscript (syntax: set.isSubsetOf(otherSet)).

<cfscript>
    setA = setNew();
    setA.add(2);
    setA.add(3);

    setB = setNew();
    setB.add(1);
    setB.add(2);
    setB.add(3);
    setB.add(4);

    writeOutput(setA.isSubsetOf(setB)); // true
    writeOutput(setB.isSubsetOf(setA)); // false
</cfscript>
      

Real-world example

Verify a request only asks for columns that exist on the table (required ⊆ allowed).

 <cfscript>
    function hasAllRequiredSkills(required any required, required any candidate) {
        return required.isSubsetOf(candidate);
    }

    required = setNew();
    required.add("A");
    required.add("B");

    candidate = setNew();
    candidate.add("A");
    candidate.add("B");
    candidate.add("C");

    writeOutput(hasAllRequiredSkills(required, candidate)); // true
</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