-2

I want to push an item into an array that in that have objects in them, like this:

var testarray = [
 {
  first: "See this?",
  second: "Oh my!"
 },
 {
  first: "Nice!",
  second: "Amazing!"
 }
]

You can see that I for this variable/array, I can't just use this testarray.push("Wonderful!"). Please show me how I can push things into these sort of arrays.

1 Answers1

2

The "multiple things" are objects. Push another object in the same format.

testarray.push({first: "Wow!", second: "Wonderful!"});
Barmar
  • 741,623
  • 53
  • 500
  • 612