I have a Javascript object nested within another object like so:
function Outer() {
this.outerProp;
this.inner = new function() {
this.innerProp;
}
}
I need to create a method to initialize the inner object. I could nest the init method inside the inner object, or I could place it outside the scope of the inner object:
var outer = new Outer();
outer.inner.init(); // Option 1
outer.initInner(); //Option 2
Would one of these options be preferred over the other? I'm leaning toward Option 1 so that I can bundle all of the data and methods related to outer.inner together. Is there any reason not to do it this way?