How can I create a two dimensional array in JavaScript?

I have been reading online and some places say it isn't possible, some say it is and then give an example and others refute the example, etc.

  1. How do I declare a 2 dimensional array in JavaScript? (assuming it's possible)

  2. How would I access its members? (myArray[0][1] or myArray[0,1]?)

Text Copied From stackoverflow.com
on : Mon, Jun 08, 2009 Views : 1447023

Accepted Answer

var items = [   [1, 2],   [3, 4],   [5, 6] ];
 console.log(items[0][0]);
 
// 1 console.log(items);

Text Copied From stackoverflow.com
on : Mon, Jun 08, 2009

Ask Question

If you want to ask question you must LogIn or SignUp
Login SignUp

Quick Links

E-Magazines

@

Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..

Ok

Login to Open ESchool OR Create your account    Login   SignUp