I have a Model that will "carry" (Model.validator) a validator instance with it, and I need the Validator to have access to the Model's attributes. So, what I have come up with is the following
var Validator = function(model) {
this.model = model;
};
var Model = function() {
this._attributes = {};
this.validator = new Validator(this);
};
var model = new Model();
This code creates a circular reference between those 2 objects. Is this a bad practice that will cause memory leaks? Any other ideas on how to implement it?
P.S. I have seen such circular references between objects in Angular.js scopes.