84
rated 0 times
[
85]
[
1]
/ answers: 1 / hits: 65039
/ 14 Years ago, wed, january 19, 2011, 12:00:00
In the following JSON object:
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.
sales : [ // Sales is another array in employees.
{ firstName : Sally, // First Element
lastName : Green,
age : 27 },
{ firstName : Jim, // Second Element
lastName : Galley,
age : 41 }
] // End sales Array.
} // End Employees
How do I restructure the object so I can access each employee first name like this:
employees[0].firstName
employees[1].firstName
// etc
More From » arrays