I have for some time wondered if there is any quicker way to instantiate a chain of objects in in javascript.
Lets say that we for instance have the following "chain of objects"
window.myobject1.myobject2.myobject3 = {}
This will ofcourse not work.. since object1 and object2 are not instantiated.. however.. to get this to work.. I would have to do something like:
window.myobject1 = {}
window.myobject1.myobject2 = {}
window.myobject1.myobject2.myobject3 = {}
Which simply just seems silly.. in a more realistic case.. lets say we have
window.server.responses.currentuser.id
where server,responses and currentuser simply act as "namespaces"/empty enities.. Would there be any way where I can tell javascript to instantiate the whole chain as objects?.. so I don't need to instantiate each part of the chain on a new line?
This might be a bad example but I guess you get it.. for instance I might also have:
window.server.responses.currentuser.id
window.server.responses.theotherusers.personone.id
window.server.responses.labels.personname
etc..
Thanks in advance!