> For the complete documentation index, see [llms.txt](https://lodash.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lodash.shujuwajue.com/math/meanby.md).

# \_.meanBy（求数组中值平均值）

**语法：**

```javascript
_.meanBy(array, [iteratee=_.identity])
```

**源代码链接：**[source](https://github.com/lodash/lodash/blob/4.17.10/lodash.js#L16349)

**npm包链接：**[npm package](https://www.npmjs.com/package/lodash.meanby)

**描述：**

这个方法类似[`_.mean`](https://lodash.com/docs/4.17.10#mean)， 除了它接受`iteratee`来调用`array`中的每一个元素，来生成其值排序的标准。 iteratee 会调用1个参数:*(value)*。

**开始版本：**&#x34;.7.0

**参数：**

* `array (Array)`: 要迭代的数组。
* `[iteratee=_.identity] (Function)`: 调用每个元素的迭代函数。

**返回值：**

* `(number)`: 返回平均值。

**例子：**

```javascript
var objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }];

_.meanBy(objects, function(o) { return o.n; });
// => 5

// The `_.property` iteratee shorthand.
_.meanBy(objects, 'n');
// => 5
```
