How to add an object to an array

How can I add an object to an array (in javascript or jquery)?
For example, what is the problem with this code?

function() {
  var a = new array();
  var b = new object();
  a[0] = b;
}

I would like to use this code to save many objects in the array of function1 and call function2 to use the object in the array.

  1. How can I save an object in an array?
  2. How can I put an object in an array and save it to a variable?

15 Answers
15

Leave a Comment