Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Required fields*

Javascript Three Dimensional Array , get error

I want to create a three dimensional array in JavaScript but I'm getting an error in Chrome:

Error: Uncaught SyntaxError: Unexpected token [ 

My JavaScript looks like this:

 function ThreeDimensionalArray(iRows,iCols,iHig)
 {
 var i;
 var j;
 var z;
 var a = new Array(iRows);
 for (i=0; i < iRows; i++)
 d {
 a[i] = new Array(iCols);
 for (j=0; j < iCols; j++)
 { 
 var a[i][j] = new Array(iHig);
 for (z=0; z < iHig; z++){
 a[i][j][z] = "";
 };
 };
 };
 return(a);
 }; 
 var hello = ThreeDimensionalArray(3,3,3);

http://jsfiddle.net/JknVF/1/

Answer*

Draft saved
Draft discarded
Cancel

lang-js

AltStyle によって変換されたページ (->オリジナル) /