javascript-collections-framework
    Preparing search index...

    Function min

    • Returns the least element of elements by comparator (natural order when omitted), the first one found among equals, or undefined when there is none. A single element is returned without a comparison. Because undefined also means "empty", an input holding only undefined cannot be told from an empty one; check size first when that matters.

      Time: O(n), exactly n − 1 comparator calls.

      Type Parameters

      • E

      Parameters

      • elements: Iterable<E>

        Any iterable.

      • Optionalcomparator: Comparator<E>

        The order; natural order when omitted.

      Returns E | undefined

      The least element, or undefined.

      TypeError when elements is not iterable, comparator is not a function, or it returns a non-number or NaN.

      NullElementError when natural order meets null or undefined.

      ClassCastError when natural order meets values of different kinds.

      min(new HashSet([3, 1, 2])) // 1
      min([]) // undefined