How do I define an object variable structure in JavaScript?
definition, javascript, object
Solution
First I would make `Offices` an array:
var Offices = [];
Then populate that with objects:
var obj = {
name: "test",
desc: "Some description",
rel: []
}
Offices.push(obj);
Now you have your array (`Offices`) populated with one object, so you could access it via `Offices[0].desc` -- you can also populate the `rel` array with `Offices[0].rel.push(anotherObj)`
Problem
I want to define something like the following object structure, so I can populate it from a number of sources. What statements do I need to define it? `Offices[]` is an open-ended array as is `rel[]` underneath it. All the elements are strings or maybe numbers. ``` Offices.name Offices.desc Offices.rel.type Offices.rel.pt ```