> For the complete documentation index, see [llms.txt](https://daseldocs.tomwright.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://daseldocs.tomwright.me/functions/mapvalues.md).

# mapValues

The `mapValues` function transforms all values of a map/object while preserving its keys. It is the map/object counterpart to [`map`](/functions/map.md), which operates on arrays.

#### Syntax

```
<object>.mapValues(expr)
```

#### Arguments

* **expr** - An expression evaluated against each value. Use `$this` to refer to the current value and `$key` to refer to the current key name.

#### Examples

**Double all values**

```
{"a": 1, "b": 2, "c": 3}.mapValues($this * 2)
// {"a": 2, "b": 4, "c": 6}
```

**Boolean expression**

```
{"a": 3, "b": 8}.mapValues($this > 5)
// {"a": false, "b": true}
```

**Transform strings**

```
{"x": "hello", "y": "world"}.mapValues(toUpper())
// {"x": "HELLO", "y": "WORLD"}
```

**Replace values with their key names using `$key`**

```
{"a": 1, "b": 2}.mapValues($key)
// {"a": "a", "b": "b"}
```

**CLI usage**

```bash
$ echo '{"a":1,"b":2}' | dasel 'mapValues($this * 2)'
{
    "a": 2,
    "b": 4
}
```

**Chained with property access**

```
{"a": 1, "b": 2}.mapValues($this + 10).a
// 11
```
