How do i create instance-able objects inside of static objects in javascript? -
i know can make static objects inside of static objects, example:
aaa: { bbb: {} ccc: {} }
but want make objects can have instantiated, that:
aaa: { bbb = function(yyy): { this.variable // 1 belong aaa(parent object) instead of instance of bbb } ccc = function(ooo) { } }
can done?
statics definition don't have 'this' reference addressing particular instance. can achieve you're trying this:
aaa: { bbb: (function() { aaa.variable = 'something'; })(), ccc: { } }
note value of bbb here return value of (self executing) function (null). seems bit of odd way of doing things though, suggest reorgainising if possible
Comments
Post a Comment