Function maxItem

Returns the maximum item from the given array.

  • If the array is empty, returns undefined.
  • If the array contains numbers, returns the maximum number.
  • If the array contains strings, returns the string with the highest lexicographical order.
  • Type Parameters

    • S extends readonly number[] | readonly string[]

      The type of the array.

    Parameters

    • source: S

      The array from which to find the maximum item.

    Returns ExtractItem<S>

    The maximum item from the array, or undefined if the array is empty.