To keep the global namespace clean, my JavaScript code is wrapped like this:
(function() { })();
Now I have some variables declared in this area that I want to access using the variable name of the variable (for example, the name 'something' + someVar ). On a global scale, I just used window['varname'] , but obviously this does not work.
Is there a good way to do what I want? If I could not just put these variables inside an object to use array notation ...
Note: eval('varname') not an acceptable solution. Therefore, please do not offer this.
source share