I have following function
function myFunction(){
var foo="My Foo String";
}
I would like to access my variable in a following way
function myFunction(){
var foo="My Foo String";
console.log(SOMETHINGIDONOTKNOWABOUT["foo"]);
}
I know in javascript its possible to use window["yourvariablename"] to access it, but I am interested to access function variable in similar way, therefor Is there a way to access a javascript variable using a string that contains the name of the variable? is not a duplicate. Eval is not correct answer for me.