declaring javascript array with multiple fields
arrays, initialization, javascript, variables
Solution
You can add values dynamically to an array using the `push()` method.
var data = [];
....
....
data.push({
"field one": "a",
"field two": "b",
})
Also if you want to add keys to an existing object dynamically, you can use the `[]` syntax
var obj = {};
...
obj['field one'] = 'a';
obj['field two'] = 'b';
data.push(obj)
Problem
So I want to declare a javascript array with multiple fields. For example I know you can do something like ``` var data = [ { "field one": "a", "field two": "b", }, { "field one": "c", "field two": "d", } ] ``` However, I don't know to do create such an array dynamically so that I don't have to initialize the fields at declaration time.