Function: max()
ts
function max(values): number;Returns the maximum value from an array of numbers. 返回数字数组中的最大值。
Parameters
| Parameter | Type | Description |
|---|---|---|
values | number[] | Array of numbers / 数字数组 |
Returns
number
The maximum value / 最大值
Throws
Error if array is empty / 如果数组为空则抛出错误
Example
typescript
max([1, 2, 3, 4, 5]) // => 5
max([-10, 0, 10]) // => 10
max([]) // throws ErrorSince
1.0.0