I have an object like this for example:
obj = {
subobj1: {
},
subobj2: {
func1: function(){
},
func2: function(){
}
},
subobj3: {
func3: function(){
},
func4: function(){
}
},
}
How do I call func1 from within func4 without having to call obj.subobj2.func1() ?
It's impossible with your implementation of the object. Depends on your needs - the following implementation could be useful:
The idea is that nested objects can't know who is their parent, but the parent can tell its children who is he (but then init. code is needed as you can see in my implementation).
You can test it here: http://jsbin.com/eVOpITom/1/edit