You cannot create a two-dimensional array in Javascript, arrays can have only one dimension. Jagged arrays, i.e. arrays of arrays, are used instead of two-dimensional arrays.
Example:
var a = [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ];
The required format that you are showing is neither a two-dimensional array nor a jagged array, it is an object that contains a property that is an array of objects. However, an object in an array has two properties with the same name, so I assume that you meant the presence of two objects in the array:
var o = { product: [ { attribute: "value" }, { attribute: "value" } ] };
You can create a similar object using a literal object, as described above, or create it by adding properties and elements of the array:
var o = {}; o.product = []; o.product.push({ attribute: "value" }); o.product.push({ attribute: "value" });
Guffa
source share