[ vujkev @ 11.08.2012. 23:44 ] @
Hteo bih da nasledim neki generički objekat, ali da svaki child objekat ima svoj niz definisan u parent-u. U primeru ispod kad kreiram Child "x2", on automatski ima sve vrednosti u nizu "collection" Code (javascript): function Parent() { var collection = []; this.add = function (i) { collection.push(i); } this.getCount = function () { return collection.length } } function Child() { Parent(this); } Child.prototype = new Parent(); Child.prototype.constructor = Child; var x1 = new Child(); x1.add(1); var x1Count = x1.getCount(); var x2 = new Child(); x2.add(1); var x2Count = x1.getCount(); var x2Count = x1.getCount(); Dakle kako napraviti child ili parent tako da kad kažem "new Child()" taj objekat ima svoj (prazan) "collection" niz |