Home > Article > Web Front-end > About the declaration method of two-dimensional array in JS
As shown below:
var myarr=new Array(); //先声明一维 for(var i=0;i<2;i++){ //一维长度为2 myarr[i]=new Array(); //再声明二维 for(var j=0;j<3;j++){ //二维长度为3 myarr[i][j]=i+j; // 赋值,每个数组元素的值为i+j } }
The above is the entire content of the declaration method of two-dimensional arrays in JS brought to you by the editor. I hope it will be helpful to everyone. Please support the PHP Chinese website~
For more related articles about the declaration method of two-dimensional arrays in JS, please pay attention to the PHP Chinese website!