Does anyone know how could I select a variable from a String in JavaScript? Here\'s what I\'m basically trying to achieve:
var myLang = \"ESP\"; var myText_
var hellos = { ESP: 'Hola a todos!', ENG: 'Hello everybody!' }; var myLang = 'ESP'; console.log(hellos[myLang]);
I don't like putting everything in global scope, and then string accessing window properties; so here is another way to do it.