> For the complete documentation index, see [llms.txt](https://docs.emobiq.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.emobiq.com/emobiq-client/006-actions-and-visual-logic/action-reference/cordova/array/pushobject.md).

# 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.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-c05f23abe9e025c10e8ce352fe931c95fbe252ed%2FpushObject-step-1.png?alt=media)
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         |

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-9269cb5bb057561bd91e2a41c298701f95c5ae10%2FpushObject-step-2.png?alt=media)
3. Finally, we use the `console` function to verify the contents of our new `sampleArr` array.

   ![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-2309c384aec0dcd5c9472799f32e6347320902cc%2FpushObject-step-3.png?alt=media)

### Result

We should expect to see this in the console.

![](https://399701567-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FwmJ1RKjM2uNFaL6fO3Xu%2Fuploads%2Fgit-blob-845a74c4c7485f661637d2236b513aa5c21bb57a%2FpushObject-result-1.png?alt=media)

## Links
