我还没有在 javascript 中尝试过嵌套数组,所以我不确定它们的格式。这是我的数组:
var items = [
{"Blizzaria Warlock", "105341547"},
{"Profit Vision Goggles", "101008467"},
{"Classy Classic", "111903124"},
{"Gold Beach Time Hat", "111903483"},
{"Ocher Helm of the Lord of the Fire Dragon", "111902100"},
{"Greyson the Spiny Forked", "102619387"},
{"Egg on your Face", "110207471"},
{"Evil Skeptic", "110336757"},
{"Red Futurion Foot Soldier", "90249069"},
{"Wizards of the Astral Isles: Frog Transformer", "106701619"},
{"Dragon's Blaze Sword", "105351545"}
];
alert(items[2][1]);
...应该提醒111903124
,但没有。
最佳答案
使用
var items = [
["Blizzaria Warlock", "105341547"],
["Profit Vision Goggles", "101008467"],
["Classy Classic", "111903124"],
...
["Dragon's Blaze Sword", "105351545"]
];
将数组构建成数组。没有理由改变语法,因为它们就在里面。
关于javascript - 嵌套数组问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16112636/