@mirei/ts-collections
    Preparing search index...

    Function contains

    • Determines whether the sequence contains a specific element using an optional comparator.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      • element: TElement

        Element to locate in the sequence.

      • Optionalcomparator: EqualityComparator<TElement, TElement>

        Optional equality comparator used to match elements. Defaults to the library's standard equality comparison.

      Returns boolean

      true when the element is found; otherwise, false.

      const numbers = [1, 2, 3, 4, 5];
      const hasThree = contains(numbers, 3);
      console.log(hasThree); // true

      const hasTen = contains(numbers, 10);
      console.log(hasTen); // false