Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Need a three dimensional array in JavaScript

Posted on 2011-10-02
5
Medium Priority
?
331 Views
Last Modified: 2012-06-27
I need an array but need each row to contain multiple data points. Is this possible?

What's the syntax?

Can I seach on any of the rows? Or just the index when retrieving a value?

Thanks.
0
Comment
Question by:newbieweb
  • 3
  • 2
5 Comments
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 36900558
var myarray = new Array(); // var myarray = [];

// method 1 to add a point
var point = [12,24,48];
myarray.push(point); //

// method 2 to add a point
myarray.push([14,28,56]);

// method 3 to add a point
myarray[myarray.length] = [1,3,5];

//your array have three points now
0
 

Author Comment

by:newbieweb
ID: 36900566
how do I pop one off the list?
0
 

Author Comment

by:newbieweb
ID: 36900619
Or, must I write a function that packs the array?
0
 
LVL 83

Assisted Solution

by:leakim971
leakim971 earned 2000 total points
ID: 36900624
myarray.pop() : http://www.w3schools.com/jsref/jsref_pop.asp
myarray.shift() : http://www.w3schools.com/jsref/jsref_shift.asp

var firstPoint = myarray[0]; // don't remove anything from th array
0
 

Author Closing Comment

by:newbieweb
ID: 36916608
Thanks!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
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…

580 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