Possible Duplicate:
How do I create Javascript array(JSON format) dynamically?
I am attempting to create the following:
var employees = {"accounting": [ // accounting is an array in employees.
{ "firstName" : "John", // First element
"lastName" : "Doe",
"age" : 23 },
{ "firstName" : "Mary", // Second Element
"lastName" : "Smith",
"age" : 32 }
] // End "accounting" array.
} // End Employees
I started out with:
var employees=new Array();
How do I continue to append to the array dynamically (might change firstName with variable)?
var employees = {accounting: []};
employees.accounting.push({
"firstName" : "New",
"lastName" : "Employee",
"age" : 18
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With