Skip to content

maxOf ​

The maxOf() function returns the largest numeric value of an array (or tuple) without touching the original.

Interactive example ​

Syntax ​

typescript
function maxOf<
	GenericInput extends readonly number[]
>(
	input: GenericInput
): number | undefined

Parameters ​

  • input: Array of numbers whose maximum is sought.

Return value ​

The largest number found, or undefined if the array is empty.

See also ​

  • minOf - Computes the minimum value
  • maxElements - Checks a maximum number of elements

Sources ​

Released under the MIT license.