> ## Documentation Index
> Fetch the complete documentation index at: https://docs.metrics-man.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Map

# \$map

The `$map` operator transforms each element in an array using a provided transformation.

## Input

* An array containing an array to map and a transformation to apply to each element

## Output

* A new array containing the transformed elements

## Examples

### Map Numbers to Doubles

```json theme={null}
{
  "$map": [
    [1, 2, 3, 4, 5],
    {
      "$multiply": [
        {
          "$var": ["current"]
        },
        2
      ]
    }
  ]
}
```

Result: `[2, 4, 6, 8, 10]`

### Transform Objects

```json theme={null}
{
  "$map": [
    [
      {"name": "Alice", "age": 25},
      {"name": "Bob", "age": 30}
    ],
    {
      "$concat": [
        {
          "$var": ["current"]
        },
        {
          "$input": "name"
        },
        " is ",
        {
          "$toString": [
            {
              "$var": ["current"]
            },
            {
              "$input": "age"
            }
          ]
        },
        " years old"
      ]
    }
  ]
}
```

Result: `["Alice is 25 years old", "Bob is 30 years old"]`
