我目前有以下数组设置:

var TicketInfo =
    {
        t1: {
            1: [7, 12, 35,39,41, 43],
            2: [7, 15, 20,34,45, 48],
            3: [3, 7, 10, 13, 22, 43],
            4: [2, 4, 5,23,27, 33]
        },
        t2: {
            1: [10, 12, 17,44,48, 49],
            2: [13, 15, 17, 18, 32, 39],
            3: [16, 17, 20, 45, 48, 49],
            4: [6, 16, 18, 21, 32, 40]
        }
        }


我想做的就是遍历这些,将数组带回到下面。

作为测试,我尝试了以下方法:

for(t in TicketInfo["t1"])
{
    i++;
        Write(t.i);
}


但这显然不符合我的要求。

有任何想法吗?

我希望能够输出像[7, 12, 35,39,41, 43]这样的数组

谢谢

最佳答案

var TicketInfo =
{
    t1: {
        1: [7, 12, 35,39,41, 43],
        2: [7, 15, 20,34,45, 48],
        3: [3, 7, 10, 13, 22, 43],
        4: [2, 4, 5,23,27, 33]
    },
    t2: {
        1: [10, 12, 17,44,48, 49],
        2: [13, 15, 17, 18, 32, 39],
        3: [16, 17, 20, 45, 48, 49],
        4: [6, 16, 18, 21, 32, 40]
    }
}

for(var j in TicketInfo )
{
    for(var p in TicketInfo[j] )
    {
        for(var i = 0; i < TicketInfo[j][p].length; i++ )
        {
             console.log(TicketInfo[j][p][i]);
        }
    }
}​


http://jsfiddle.net/J6rTj/

10-07 14:44