Andrew Poulos wrote:
> myArray = [[0,1],[2,3]];
> and a string that looks like:
> str = “1_1”;
> foo = str.split(“_”); // foo now equals [“1”,”1”]
>
> Then how can I use foo as an index? That is, something like
>
> bar = myArray[foo]; // bar should now equal 3
Is this what you're looking for?!
function navigate(o, path){
for(var x; (x = path.shift()) != undefined && o[x] != undefined; o = o[x]);
return o;
}
var x = [[0,1],[2,3]];
alert(navigate(x, [1, 1]));
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com