Function getDifference

  • Represents the difference set operation, where the difference is the set of elements in set B that are not in set A.

    • Formal definition: B \ A = {x: x ∈ B | x ∉ A}
    • This method runs in linear time, or O(n), where n = |B| (size of set B).
    • 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 <TElement> elements

    Returns Set<TElement>

    Difference of A and B

    See

    Set.prototype.difference

    Example

    //{1, 2, 3} \ {3, 5} = {1, 2}
    getDifference(new Set([1, 2, 3]), new Set([3, 5])); // new Set([1, 2])

Generated using TypeDoc