Trying to answer a question in stackoverflow, I was doing some tests in my chrome console, and found the following case I am not able to understand.
var vals = ['x','y','z'];
vals.forEach(val => { eval(`var ${val} = 1; console.log('${val} = ', ${val})`);});
How can javascript know when I am refering to ${val} as the val defined in "vals" array, and when I am refering to the value it has stored each value in that array?
I mean, why it does not log:
x = x;
y = y;
z = z;
or
1 = 1;
1 = 1;
1 = 1;