• Checks if two sets are equal, where two sets have the same number of elements, and same elements themselves

    • Formal definition: A = B means ∀z, (z ∈ x ⇔ z ∈ y)
    • This method runs in linear time, or O(n), where n = |A| (size of set A).
    • Note: This does not check for reference/entity equality, but rather value equality.

    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

    // {1, 2, 3, 4} = {1, 2, 3, 4}
    areSetsEqual(new Set([1, 2, 3, 4]), new Set([1, 2, 3, 4])); // true

    // {hello, world} = {hello, world}
    areSetsEqual(new Set(['hello', 'world']), new Set(['hello', 'world'])); // true

Generated using TypeDoc