Solved

Best way of creating 2D Javascript Array

Posted on 2011-09-27
1
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 36711427
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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…

691 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