Using Bracket Notation Opposed To Eval
I have the following var module = function(){ console.log('module ran') } var someString = 'module' [string]() //TypeError: object is not a function eval(someString)() // wo
Solution 1:
Bracket notation is used to access object properties. If that's on the global scope (and if you're on a browser), you can use this:
window[someString]();
Post a Comment for "Using Bracket Notation Opposed To Eval"