Skip to content

Function: min()

ts
function min(values): number;

Returns the minimum value from an array of numbers. 返回数字数组中的最小值。

Parameters

ParameterTypeDescription
valuesnumber[]Array of numbers / 数字数组

Returns

number

The minimum value / 最小值

Throws

Error if array is empty / 如果数组为空则抛出错误

Example

typescript
min([1, 2, 3, 4, 5]) // => 1
min([-10, 0, 10]) // => -10
min([]) // throws Error

Since

1.0.0

Released under the MIT License.