pushObject
Description
Adds an object to an array.
Input / Parameter
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
The updated array with the object added.
Array/List
Callback
N/A
Video
Coming Soon.
Example
Coming Soon.
Steps
First we will create an existing array with the
setVarfunction.For "var" we will use the name
sampleArr.For "value", we will use the
toObjectfunction to pass the name and email values.
Next, we will use the
pushObjectfunction to add an object to our existingsampleArrcreated in step 1.FieldValuevar
sampleArr
key
gender
value
M

Finally, we use the
consolefunction to verify the contents of our newsampleArrarray.
Result
We should expect to see this in the console.

Links
Last updated