gpt4 book ai didi

javascript - 创建带有变量索引的多维数组

转载 作者:行者123 更新时间:2023-12-03 08:43:17 24 4
gpt4 key购买 nike

我想这样做:

var array=new Array();

//I have an array
//[0]{category:'1',page:'2',row:'3',column:'4',description:'boh',id:'0'};
//[2]{category:'2',page:'2',row:'4',column:'4',description:'bah',id:'2'};

//for cycle for order the original object
object.forEach(function(obj){

问题在于:如何通过对象值设置这个多维数组的索引?

    array[category][page][row][column] = obj;

}

//then with another cycle
for(var a=0;a<category.length;a++){
for(var b=0;b<page.length;b++){
console.log(array[a][b][c][d].description);
}
}

最佳答案

you can create multi dimentional array bu this

var myarray=new Array(3)
for (i=0; i <3; i++)
myarray[i]=new Array(5)

关于javascript - 创建带有变量索引的多维数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32994579/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com