For example:
function userObject(start_value) {
this.name = start_value;
this.address = start_value;
this.cars = function() {
this.value = start_value;
this.count = start_value;
};
}
Obviously the above dosent work but would appreciate the direction to take to have cars available as:
userObject.cars.value = 100000;
Cheers!
Remember that functions (and thus “object definitions”) can be nested (there is absolutely no requirement that this is nested, but having it nested here allows a closure over
start_value):However, I would likely opt for this (just create a new “plain” Object):
Happy coding.