Solved

Best way of creating 2D Javascript Array

Posted on 2011-09-27
1
169 Views
Last Modified: 2012-05-12
Hello Experts,

Some advice needed please.

Currently, I am having a problem trying to create a 2D array.

My code is as follows:

Notes:
1. marker is an array
2. Earlier in my code, I have declared:

var myArray = new Array();


var index1 = 123;
vat index 2 = 456;
myArray[index1][index2].push(marker)

Open in new window


Therefore, at the end of this procedure, I expect to be able to grab this marker using:

myArray[123][456]

However the myArray[index1][index2].push(marker)


The error I get is:
"Error: 'myArray[...]' is null or not an object"

What am I doing wrong?
Is this the best way of assigning/retrieving data from a 2D array?

Thanks!
0
Comment
Question by:jagku
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36711427
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
how can i make 2 columns? 4 36
Make Session back to empty 9 30
How  can  I extract  Id  from a  URL  using  Javascript? 12 29
Copying table data to one another 15 29
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question