Is it possible? I'm trying to do the following thing:
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
Although it's obvious to define value when you know where the binding value exist ,x in this case, it's hard to bind a value to values with unknown location, y in this case.
Any thoughts? Thanks.
you should probably read up on how variables are passed in javascriptTopic Closeraround here since they basically destroy value of this site.