var ids = 1; var myParentClass = (function(){ var _protected_prop = {}; return new Class({ initialize: function(id, par1, par2) { this.id = id; _protected_prop[this.id] = {}; _protected_prop[this.id].prop1 = 'myvalue1'; _protected_prop[this.id].prop2 = true; _protected_prop[this.id].prop3 = 65; }, protectedProp: function() { return _protected_prop[this.id]; }.protect(), changeProp: function(value) { _protected_prop[this.id].prop1 = value; } }); }()); var myChildClass = (function() { var _protected_prop = {}; return new Class({ Extends: myParentClass, initialize: function(par1, par2, par3) { var id = ids++; this.parent(id, par1, par2); // here the protected prop of the parent are ready _protected_prop[this.id] = { prop4: 'myvalue4', prop2: false }; _protected_prop[this.id] = Object.merge(this.protectedProp(), _protected_prop[this.id]); }, test: function() { $('test_result').appendText(_protected_prop[this.id].prop1 + ' '); } }); }()); var c = new myChildClass(1, 2, 3); c.test(); c.changeProp('myalteredvalue'); c.test();
<div id="test_result">risultati: </div>