How to append to a JavaScript array dynamically?
javascript
Solution
var employees = {accounting: []};
employees.accounting.push({
"firstName" : "New",
"lastName" : "Employee",
"age" : 18
});
Problem
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)?