How would I go about creating a graph like data structure in javascript? I want to have a link within the structure that points some where else within the structure.
Like in this example:
var MenuLayout = {
home: {
buttons: [{
text: "Identify Tree",
link: MenuLayout.treeid
}, {
text: "Plant"
}, {
text: "Information"
}, {
text: "Enter Tree"
}]
},
treeid: {
buttons: [{
text: "Something Else"
}]
}
};
In this example I would like MenuLayout.home.buttons[0].link
point to MenuLayout.treeid
node. Is there a way to get it to point to that?
NOTE: I want this to work for an arbitrary order of declaration.