Is it possible to use an array variable value as a new variable name in a for-loop (or in other words, can the left-hand side of an equation be determined by a pre-defined value in an iteration)?
for (var i = 0; i < array.length; i++) {
// we all know this is possible:
blabla[i] = apple;
// but I'm wondering if there's a way we can achieve this:
example(someVar);
}
function example(name) {
// [name] = banana;
name = banana;
}
Obviously, the way I'm doing this in the snippet above, the value banana
is always getting assigned to the variable name
. Not too sure though how I could go about this?