To answer your question, no, there is no way to do dynamic variable lookup in a local scope without using eval()
.
The best alternative is to make your “scope” just a regular object [literal] (ie, "{}"
), and stick your data in there.
More Related Contents:
- How do JavaScript closures work?
- JavaScript variable with global scope [closed]
- Javascript: Do I need to put this.var for every variable in an object?
- var self = this?
- Is the underscore prefix for property and method names merely a convention?
- Can I access variables from another file?
- Global variables in Javascript across multiple files
- What is the correct term for variable shadowing in JavaScript?
- What underlies this JavaScript idiom: var self = this?
- JavaScript variable binding and loop
- array.length is zero, but the array has elements in it [duplicate]
- JavaScript Callback Scope [duplicate]
- JavaScript loop variable scope
- Is window really global in Javascript?
- Node.js variable declaration and scope
- javascript: recursive anonymous function?
- Variables set during $.getJSON function only accessible within function
- How can I return a variable from a $.getJSON function
- JavaScript scope and closure
- Why was block scope not originally implemented in JavaScript?
- JavaScript Variable Scope [duplicate]
- What happens when JavaScript variable name and function name is the same?
- Is event a global variable that is accessible everywhere inside the callback chain?
- Passing a global variable to a function
- Why does .then() chained to Promise.resolve() allow const declaration to be reassigned?
- Scope issues with Angular UI modal
- Function not calling within an onclick event
- Javascript scope addEventListener and this
- How to set javascript private variables in constructor?
- Programmatically accessing function scope using Chrome DevTools console