Solved

Best way of creating 2D Javascript Array

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…
Suggested Courses

737 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