Can it be done? I'm attempting to achieve the following:
var foo = 'foo';
var bar = 'bar';
var x;
var y;
var array1 = [x, [foo, y]];
var array2 = [x, [foo, bar], [foo, y]];
console.log(array1[0]); //undefined
console.log(array1[1][1]); //undefined
console.log(array2[0]); //undefined
console.log(array2[2][1]); //undefined
array1[0] = 'working';
array2[0] = 'working';
y = 'hello';
console.log(array1[0]); //working
console.log(array1[1][1]); //undefined
console.log(array2[0]); //working
console.log(array2[2][1]); //undefined
While it's easy to assign a value when you know where the binding value is located, x
in this scenario, it becomes difficult to bind a value to values with unknown location, y
in this case.
Any ideas or suggestions? Thank you.