I suspect this has been asked and answered, but i couldn't find it. I'm new to js and am wondering if memory or performance hits occur when maintaining a parent reference in child objects? For instance, suppose this:
var phoneViewModel = function (number, parent) {
var self = this;
self.number = number;
self.parent = parent;
deleteNumber = function () {
self.parent.phones.pop(this);
}
}
var personViewModel = function (name) {
var self = this;
self.name = name;
self.phones = [];
self.addPhone = function (number) {
self.phones.push(new phoneViewModel(number, self));
};
}
If the person data comes out to 1mb, and they have 100 phone numbers, will I use up ~100mb (I suppose it would be an exponential number if this is true)? Or will it just be the ~1mb?
Another way to ask this is, is there any reason to avoid this practice?