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

    Function max

    • Returns the largest 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 maximum 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 = [1, 5, 2, 4, 3];
      const maxNumber = max(numbers);
      console.log(maxNumber); // 5

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