# replace

```erlang
replace :: (Number index, Any value, Array input) => Array output
```

## description

Returns a new array after replacing the value at the provided `index` with the provided `value` in the `input` array. If the index is not found, the input array is simply (shallow) cloned.

Like nearly all methods in conductor, replace is a pure function and will not modify the input array.

{% hint style="info" %}
Like nearly all methods in **conductor**, `replace` is a *pure function* and will not modify the input array.
{% endhint %}

## example

```javascript
import { replace } from 'conductor'

const numbers = [3, 1, 1]
replace(2, 4, numbers) // [3, 1, 4]
```

Here, we simply replaced the value at index `2` by the value 4.


---

# 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://conductor.js.org/1.3.0/api-reference/replace.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.
