function recursiveSearch what where var depth new Object depth depth f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function recursiveSearch(what, where) {
var depth = new Object();
depth.depth = [];
function search(what, where, depth) {
if (typeof where == 'object') {
depth.depth.push(0);
for (var i=0; i < where.length; i++) {
depth.depth[depth.depth.length - 1] = i;
search(what, where[i], depth);
}
depth.pop();
} else {
if (what == where) {
throw "Done!";
}
}
}
try {
search(what, where, depth);
} catch (e) {
if (e == "Done!") return depth;
}
}