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

    Function min

    • Returns the smallest numeric value produced for the elements in the sequence.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      • Optionalselector: Selector<TElement, number>

        Optional projection that extracts the numeric value for each element. Defaults to the element itself.

      Returns number

      The minimum of the projected values.

      Thrown when the sequence is empty.

      The entire sequence is enumerated exactly once. Provide a selector when the elements are not already numeric.

      const numbers = [3, 1, 5, 2, 4];
      const minNumber = min(numbers);
      console.log(minNumber); // 1

      const people = [
      { name: 'Alice', age: 25 },
      { name: 'Bob', age: 30 },
      { name: 'Charlie', age: 22 },
      ];
      const minAge = min(people, p => p.age);
      console.log(minAge); // 22