javascript - 嵌套数组问题

标签 javascript arrays

我还没有在 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/

相关文章:

javascript - 如果数组的开头有共同部分,如何从数组中删除元素?

javascript - 包装组件意味着它失去了对重新渲染的关注

javascript - Console.log = null 对于我手动设置的值

javascript - 选择 Kendo UI ListView 项

javascript - 在不同文件中导出不同路由的实际函数

javascript - React + Redux-router = Uncaught Error : Expected the reducer to be a function

arrays - 具有重复项的 Powershell 组哈希数组

javascript - 如何按给定的组数创建一系列数字的通讯组

java - 为什么这个基于数组的 Java 游戏不起作用?

java - 使用java的数组的所有可能子序列