Probably not the correct word. But I want to create a new type in JavaScript. It would have the simple property that one could do this:
var inst = new SomeType();
inst.key1.key2 = 'something';
inst.key1.key1.key3 = 'something';
Basically you wouldn't have to declare an object literal to extend further. It would create one automatically.
This would allow me to build complex structures without having to worry about checking for the existence of a property to extend off of.
Instead of doing
inst.key1 = {};
inst.key1.key2 = 'data';
one could just do
inst.key1.key2 = 'data';
and the
inst.key1 = {};
would be automatic, i.e. would happen internally.
This does have a practical purpose. Particularly I have a registry pattern which I would use this new type to organize data using a more hierarchical approach.
Also, I see a pattern, common in libraries, that tests for the existence of an object literal and then creates one if it does not exist.
This is a common idiom it seems.