Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function getPositionInMatrix(needle, haystack, pos)
{
    pos = pos || [];
    for(var i = haystack.length; --i >= 0;)
    {
        if(haystack[i] === needle)
        {
            return pos.push(i);
        }
        else if(Object.prototype.toString.call(haystack[i]) === '[object Array]')
        {
            pos.push(i);
            if(getPositionInMatrix(needle, haystack[i], pos))
            {
                return pos;
            }
            else
            {
                pos.pop();
            }
        }
    }
    return false;
}