# Map

The `map` method iterates over an array and modifies its elements using a callback function. The callback function will then be applied to each element of the array.

```javascript
const numbers = [2, 4, 6, 8];

const numbersTimesTwo = numbers.map(number => number * 2);

console.log(numbersTimesTwo);

// Result: [4, 8, 12, 16]
```

Here, the `map` method returns a new array with the results and preserves the old one. To assign this, a new variable is used.

{% hint style="info" %}
The `map()` method doesn't execute function for empty elements and doesn't change the original array.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://js201.gitbook.io/js-101/arrays/map.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
