A
Andrew Poulos
If I'm searching for an occurance of a value in a multi-dimensional
array how can I get it's index returned as an array, if found? For
example, if:
foo = new Array();
foo = [1, 2, 3, [4, '4a'], 5, [6, 7, 8], 9, 10];
Array.prototype.findValue = function(val) {
// blah
}
var foundInd = foo.findValue(8);
Then searching for 8 returns [5, 2] and searching for 'fred' returns,
say, -1. It's seemed simple enough with a one dimensional array but I'm
stuck when the array is multi dimensional.
Andrew Poulos
array how can I get it's index returned as an array, if found? For
example, if:
foo = new Array();
foo = [1, 2, 3, [4, '4a'], 5, [6, 7, 8], 9, 10];
Array.prototype.findValue = function(val) {
// blah
}
var foundInd = foo.findValue(8);
Then searching for 8 returns [5, 2] and searching for 'fred' returns,
say, -1. It's seemed simple enough with a one dimensional array but I'm
stuck when the array is multi dimensional.
Andrew Poulos