# Array

### Array Push

*Add an `newItem` to the end of an array.*

#### Expression:

**ARR\_PUSH**(*stack*: array\[], *newItem*: any)

#### Return:

*array*\[]

#### Example of usage:

```javascript
ARR_PUSH(["apples","pears"], "oranges")

Return value:
["apples","pears","oranges"]
```

### Array Splice

*Trim an array of elements bordered by indexes; optionally, can add new elements.*

#### Expression:

**ARR\_SPLICE**(*stack*: array\[], *index*: number, *deleteCount*: number, *newItems?*: any)

#### Return:

array\[]

#### Example of usage:

```javascript
ARR_SPLICE(["apples","pears","oranges"], 0, 2, "bananas")

Return value:
["oranges","bananas"]
```

### Array Sum

*Returns a sum of all numeric values of Array elements.*

#### Expression:

**ARR\_SUM**(*stack*: array\[])

#### Return:

float

#### Example of usage:

```javascript
ARR_SUM([1, 2, 3])

Return value:
6
```

### Array Map

*Returns second argument (as an expression) for each array element.*

{% hint style="info" %}
Variables *item, index* are available in the expression, representing listed item.
{% endhint %}

#### Expression:

ARR\_MAP(*stack*: array\[], filter: expression)

#### Return:

array\[]

#### Example of usage:

```javascript
ARR_MAP([{a:"hello", b:"bye"},{a:"hi", b:"see ya"}], item.a)

Return value:
["hello","hi"]
```

### Array Filter

*Return matched array pattern in comparison with the second expression argument.*

{% hint style="info" %}
Variables *item, index* are available in the expression, representing listed item.
{% endhint %}

#### Expression:

**ARR\_FILTER**(*stack*: array\[], filter: expression => boolean)

#### Return:

array\[]

#### Example of usage:

```javascript
ARR_FILTER(["hello","hi","how are you"], item == "hello")

Return value:
["hello"]
```

### Array Reduce

*Reduces provided array by calling a second argument (as an expression).*

{% hint style="info" %}
Variable 'previousValue', 'currentValue' and 'currentIndex' are available in an expression.
{% endhint %}

#### Expression:

**ARR\_REDUCE**(*stack*: array, {*previousValue* || *currentValue* || *currentIndex*})

#### Return:

float

#### Example of usage:

```javascript
ARR_REDUCE([1, 2, 3, 4], previousValue + currentValue)

Return value:
10
```

### Array Find

*Returns `array of indexes` for which the expression returns `true`.*

{% hint style="info" %}
Variable 'item' and 'index' are available in the expression.
{% endhint %}

#### Expression:

ARR\_FIND(*stack*: array, filter: expression)

#### Return:

array\[]

#### Example of usage:

```javascript
ARR_FIND(["apples","pears","oranges"], item == "oranges")

Return value:
[2]
```

### Includes

*Returns `true` if an item is included in an array.*

#### Expression:

**INCLUDES**(*array*: any, *item*: any)

#### Return:

boolean

#### Example of usage:

```javascript
INCLUDES([1,2,3],2)

Return value:
true
```


---

# 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://docs.adapptio.com/reference-guide/functions/array.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.
