在数组中的数组中选择值;Javascript

在数组中的数组中选择值;Javascript,javascript,arrays,Javascript,Arrays,我有一个数组,正好用数组填充:[[1,“thing”],[2,“other thing”],[3,“still other thing”]]我希望能够在其中一个数组中选择一个值,而不必将数组设为临时变量,然后选择项。可以这样做吗?您可以使用相同的“[]”语法索引到嵌套数组中 var arr = [[1, "thing"], [2, "other thing"], [3, "still other thing"]]; console.log(arr[0]); // [1, "thing"] con

我有一个数组,正好用数组填充:
[[1,“thing”],[2,“other thing”],[3,“still other thing”]]
我希望能够在其中一个数组中选择一个值,而不必将数组设为临时变量,然后选择项。可以这样做吗?

您可以使用相同的“[]”语法索引到嵌套数组中

var arr = [[1, "thing"], [2, "other thing"], [3, "still other thing"]];
console.log(arr[0]); // [1, "thing"]
console.log(arr[0][0]); // 1
作为参考


在该链接中搜索二维

哦,太完美了。我真不敢相信我没有想到这一点。