es-toolkit/docs/zh_hans/reference/math/mean.md
BlackWhite e9ede74362
docs: Translate Simplified Chinese (#165)
* Translate Simplified Chinese

* Supplement the omitted

* Supplement the omitted

* Supplement the omitted

* Supplement the omitted

* Supplement the omitted

* Supplement the omitted

* Supplement the omitted

* Supplement the omitted

* Supplement the omitted

* Update docs/.vitepress/shared.mts

---------

Co-authored-by: Sojin Park <raon0211@gmail.com>
2024-07-12 10:08:55 +09:00

414 B

mean

计算数字数组的平均值。

如果数组为空,则此函数返回 NaN

签名

function mean(nums: number[]): number;

参数

  • nums (number[]): 要计算平均值的数字数组。

返回值

(number): 数组中所有数字的平均值。

示例

const numbers = [1, 2, 3, 4, 5];
const result = mean(numbers);
// result 将会是 3