Javascript multidimentional相关数组错误

时间:2015-10-16 06:39:01

标签: javascript arrays multidimensional-array

我要构建两个相关的数组,但是会出错

while(phpcnt)
{
    pre_id=id
    pre_selected[track]['id']=some id;
    pre_selected[track]['price']=some no;
    console.log(pre_selected[track]['id']);
    console.log(pre_selected[track]['price']);
    phpcnt=phpcnt-1;
    track=track+1;
}

这是数组声明    var pre_selected=new Array();

,错误为TypeError: pre_selected[track] is undefined

0 个答案:

没有答案