-3

How Do we use Three Dimensional Array in Javascript?

Please show a basic example.

4
  • 4
    I believe you haven't tried or searched anything. Commented Jul 17, 2014 at 7:54
  • possible duplicate of Is it possible to create an empty multidimensional array in javascript/jquery? Commented Jul 17, 2014 at 7:56
  • yes i did but couldnt understand the concept that what is the use of this when we can do with normal array Commented Jul 17, 2014 at 7:57
  • Use of 3 dimensional is to store values like data of 3*3 rubic cube Commented Jul 17, 2014 at 7:58

1 Answer 1

6

Multi dimensional array can be created like we create Single dimensional array in Javascript.

Creating Multi Dimensional array can be done by following:

var myArr = new Array();
myArr[0] = new Array();
myArr[0][0] = new Array()
myArr[0][0][0] = "test";
myArr[0][0][1] = "testnew";

alert(myArr[0][0][1]); 

There is also another way to do it, to create 3 Dimensional array without assigning values:

var myArr = new Array(new Array(new Array()));
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.