# pushObject

## Description

Adds an object to an array.

## Input / Parameter

| Name  | Description                                  | Input Type  | Default | Options | Required |
| ----- | -------------------------------------------- | ----------- | ------- | ------- | -------- |
| var   | The array of values to add an object to.     | String/Text | -       | -       | Yes      |
| key   | The index of the array to add the object to. | String/Text | -       | -       | Yes      |
| value | The value of the object to add to the array. | String/Text | -       | -       | Yes      |

## Output

| Description                              | Output Type |
| ---------------------------------------- | ----------- |
| The updated array with the object added. | Array/List  |

## Callback

N/A

## Video

Coming Soon.

## Example

Coming Soon.

### Steps

1. First we will create an existing array with the `setVar` function.

   For "var" we will use the name `sampleArr`.

   For "value", we will use the `toObject` function to pass the name and email values.

   ![](/files/zcg2UStrroJ0Kpy94SNy)
2. Next, we will use the `pushObject` function to add an object to our existing `sampleArr` created in step 1.

   | Field | Value     |
   | ----- | --------- |
   | var   | sampleArr |
   | key   | gender    |
   | value | M         |

   ![](/files/knvUAjaVM97bYh87KqaD)
3. Finally, we use the `console` function to verify the contents of our new `sampleArr` array.

   ![](/files/gsUJgXphzHW48QlSsp6p)

### Result

We should expect to see this in the console.

![](/files/DqUXujabSVuT42zcAtYx)

## Links


---

# 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.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/array/pushobject.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.
