我正在尝试创建一个多维数组。
我假设以下结构stuff['mykey1']['mykey2']['mykey3']
可以解释为stuff
二维数组的数组。并将stuff['mykey1']
返回一个带有以下键的二维数组['mykey2']['mykey3']
我尝试像这样创建这个结构:
var stuff = null;
if(stuff === null)
{
stuff = []; // stuff is []
}
if(stuff[userId] === undefined)
{
stuff[userId] = []; // stuff is [undefined, undefined, undefined, 888087 more...]
}
if(stuff[userId][objectId] === undefined)
{
stuff[userId][objectId] = [];
}
但是,当我一步一步查看 stuff 数组时,我看到了stuff[userId] = []
; 东西数组是[undefined, undefined, undefined, 888087 more...]
我期待 [888087, []]
未定义的值从何而来?