Function areSetsEquivalent

  • Compares the cardinality of two sets; that is, compares the size of the two sets to see if they are equal.

    • Formal definition: |A| = |B|
    • This method runs in constant time, or O(1).

    Type Parameters

    • TElement

    Parameters

    • a: Set<TElement>

      Set A of type <TElement> elements

    • b: Set<TElement>

      Set B of type <TElement> elements

    Returns boolean

    Whether |A| = |B| is true

    Example

    // |{A, B, C}| = |{D, E, F}|
    areSetsEquivalent(new Set(['A', 'B', 'C']), new Set(['D', 'E', 'F'])); // true

Generated using TypeDoc