Solved

Best way of creating 2D Javascript Array

Posted on 2011-09-27
1
168 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

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 remove string values 2 29
javascript comparing two dates 3 18
Jquery 10 19
Adding Row and Cell on a table 14 17
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

776 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