A
Andrew Poulos
Say I have a multi-dimensional array and I have an index (held in a
variable) that is itself an array, how do I get the array element that
is referred to. For example,
myArray = [1, [2, [3, 4]], 5];
ind = [1,1,1]; // it's pointing to the value 4
I've tried unsuccessfully
myArray[ind];
myArray.ind;
myArray.eval(ind);
fGetValue = function(ind) {
var el;
for (var i = 0; i<ind.length;i++) {
el = myArray[ind];
// ??? a mess of spaghetti code
}
return el;
}
Andrew Poulos
variable) that is itself an array, how do I get the array element that
is referred to. For example,
myArray = [1, [2, [3, 4]], 5];
ind = [1,1,1]; // it's pointing to the value 4
I've tried unsuccessfully
myArray[ind];
myArray.ind;
myArray.eval(ind);
fGetValue = function(ind) {
var el;
for (var i = 0; i<ind.length;i++) {
el = myArray[ind];
// ??? a mess of spaghetti code
}
return el;
}
Andrew Poulos