var a = {};
a.__defineGetter__('test',function() {return 5;});
var i ="test";
Is there any other way that I can execute getter besides a[i](when using var ifor this)
EDIT:
I asked to use var ifor this purpose. I will explain the real problem a little better.
I use getters on my namespace object to load modules only when necessary.
MyNameSpace.__defineGetter__('db',function(){MyNameSpace.loadModule('db');});
In this case, I try to load all the modules:
for (var i in MyNameSpace){
MyNameSpace[i];
}
I use the Google closure compiler for my code and reduce this loop above to:
for(var i in MyNameSpace);
No modules are loading. I am trying to trick gcc to load modules.
source
share