> For the complete documentation index, see [llms.txt](https://gu-xionghong.gitbook.io/lodash-analysis/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gu-xionghong.gitbook.io/lodash-analysis/math/mean.md).

# mean

> "Let go of the thoughts that don't make you strong." —Unknown

本文为 《lodash 源码阅读》 系列文章，后续内容会在 [github](https://github.com/gu-xionghong/lodash-analysis) 中发布，欢迎 star，[gitbook](https://gu-xionghong.gitbook.io/lodash-analysis/) 同步更新。

## 依赖

```javascript
import baseMean from './meanBy.js';
```

* [lodash 源码阅读 —— meanBy](/lodash-analysis/math/meanby.md)

## 源码

```javascript
/**
 * 计算 array 的平均值。
 *
 * @since 4.0.0
 * @category Math
 * @param {Array} array 要迭代的数组。
 * @returns {number} 返回平均值。
 * @example
 *
 * mean([4, 2, 8, 6])
 * // => 5
 */
function mean(array) {
  return baseMean(array, value => value);
}
```

## 原理

传入返回自身的 `iteratee` 给 `meanBy` 方法，计算普通一维数组的平均值。

## 相关链接

* [lodash 源码阅读 —— meanBy](/lodash-analysis/math/meanby.md)
