Noob question here :) Is there any way to access the value of a variable name refereed dynamically in javascript ?
What I tried :
var var1 = "foo";
var var2 = "bar";
var i = 1;
i++;
console.log(`var${i}`); // give me "var2"
console.log(typeof `var${i}`); // == srting`
I want to access the value "foo" or "bar" but i'm missing something as I get only the name of the variable ?
My first question on stack, so if it's not perfect let me know I will add details, thank you !