The array of numbers.
The maximum value from the array.
Throws an error if the array length is 0.
const numbers = [1, 3, 2, 5, 4];
const maxNumber = max(numbers);
console.log(maxNumber);
// Output: 5
Returns the maximum value from an array of bigints.
The array of bigints.
The maximum value from the array.
Throws an error if the array length is 0.
const bigints = [BigInt(1), BigInt(3), BigInt(2), BigInt(5), BigInt(4)];
const maxBigInt = max(bigints);
console.log(maxBigInt);
// Output: 5n
Returns the maximum value from an array using a custom numerical implementation.
The type of the elements in the array.
The array of elements.
Optional
numerical: Numerical<T>The numerical implementation to use.
The maximum value from the array.
Throws an error if the array length is 0 or if no appropriate numerical implementation is provided.
const array = [1, 3, 2, 5, 4];
const maxElement = max(array, new NumericalNumber());
console.log(maxElement);
// Output: 5
Generated using TypeDoc
Returns the maximum value from an array of numbers.