max
mathComputes the maximum value of array. If array is empty or falsy, undefined is returned.
Signature
max<T extends number>(array: T[]): T | undefinedParameters
| Name | Type | Description |
|---|---|---|
array | T[] | The array to iterate over |
Returns
T | undefined - Returns the maximum value
Examples
Basic usage
import { max } from 'dashlite'
const result = max([4, 2, 8, 6])
console.log(result)Output:
8Empty array
import { max } from 'dashlite'
const result = max([])
console.log(result)Output:
undefinedAvailable since version 1.0.0