Function getIntersection

  • Represents an intersection set operation, which are the elements that exist in both set A and set B.

    • Formal definition: A ∩ B = {x: x ∈ A & x ∈ B}
    • This method runs in bilinear time, or O(n * m), where n = |B| (size of set B) and m = |A| (size of set A).
    • This method has no side effects, returning a new Set<TElement> instance.

    Type Parameters

    • TElement

    Parameters

    • a: Set<TElement>

      Set A of type <TElement> elements

    • b: Set<TElement>

      Set B of type <B> elements

    Returns Set<TElement>

    Intersection of A and B

    See

    Set.prototype.intersection

    Example

    // {1, 2, 3, 4} ∩ {3, 4, 5, 6} = {3, 4}
    getIntersection(new Set([1, 2, 3, 4]), new Set([3, 4, 5, 6])); // new Set([3, 4])

Generated using TypeDoc