# \_.mapValues

**语法：**

```javascript
_.mapValues(object, [iteratee=_.identity])
```

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

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

**描述：**

创建一个对象，这个对象的key与`object`对象相同，值是通过`iteratee`运行`object`中每个自身可枚举属性名字符串产生的。`iteratee`调用三个参数：*(value, key, object)*。

**开始版本：**&#x32;.4.0

**参数：**

* `object (Object)`: 要遍历的对象。
* `[iteratee=_.identity] (Function)`: 每次迭代时调用的函数。

**返回值：**

* `(Object)`: 返回映射后的新对象。

**例子：**

```javascript
var users = {
  'fred':    { 'user': 'fred',    'age': 40 },
  'pebbles': { 'user': 'pebbles', 'age': 1 }
};

_.mapValues(users, function(o) { return o.age; });
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)

// The `_.property` iteratee shorthand.
_.mapValues(users, 'age');
// => { 'fred': 40, 'pebbles': 1 } (iteration order is not guaranteed)
```
