- Home /
How To Create 2D Arrays
So Right now, Im trying to create 2D Arrays with JavaScript. What I mean by 2D Arrays is like the following image before (I'm Pretty Sure It's A 2D Array) So how would you go around creating this in Javascript?
Comment
Answer by daviddan2010 · Nov 22, 2010 at 12:52 AM
this should be what you're looking for... somewhat of a vague question but im sure it will get you started at least.
var Element = new Array(numberOfElements);
for(x=0; x < numberOfElements; x++){ Element[x] = new Array(numberOfCols); }
//then you can access the elements by... Element[elementIndex, colIndex];
this actually looks like a 3d array to me. At the top left of the image it says rows, elements, then cols. regardless it would be the same concept.
Your answer
![](https://koobas.hobune.stream/wayback/20220613083924im_/https://answers.unity.com/themes/thub/images/avi.jpg)