473,396 Members | 1,671 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

two dimensional arrays

Max
I would like to create a two dimensional array.
I would like an array where I can store 4 variables like (Artist, Track,
Album, Time) like per Element so I can access it later by element and
variable like:

var newVar = myArray[0].Artist

Would anybody know if it is possible and give me an example for the code.
Thanks

Max

Jul 20 '05 #1
3 3886
Max wrote:
I would like to create a two dimensional array.
No, you would like to create an array of objects.
I would like an array where I can store 4 variables like (Artist, Track,
Album, Time) like per Element so I can access it later by element and
variable like:
// define the object prototype
function PlaylistItem(sArtist, sAlbum, sTrack, nTime)
{
this.artist = sArtist || "";
this.album = sAlbum || "";
this.track = sTrack || "";
this.time = nTime || -1;
}

// create array of PlaylistItem objects
var myArray = new Array(
new PlaylistItem(
"The Corrs",
"Unplugged",
"Lough Erin Shore",
4 + 25/60),
...);
var newVar = myArray[0].Artist


var newVar = myArray[0].artist;
HTH

PointedEars

Jul 20 '05 #2
On Fri, 7 Nov 2003 19:02:47 -0000
"Max" <ga*****@ntlworld.com> wrote:
<snip>
... so I can access it later...

<snip>

Later in the same script or later in the sense of persistence across
sessions?

--
Life is an offensive, directed against the repetitious mechanism of the
Universe.
--Alfred North Whitehead (1861-1947)
Jul 20 '05 #3
> I would like to create a two dimensional array.
I would like an array where I can store 4 variables like (Artist, Track,
Album, Time) like per Element so I can access it later by element and
variable like:

var newVar = myArray[0].Artist


var myArray = [
{Artist: "Gut", Track: "Do the Gorilla", Album: "Songs in the Key of E",
Time: 3.5},
{Artist: "Gut", Track: "The Vision", Album: "Songs in the Key of E", Time:
3.65}];

http://www.JSON.org

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Parrot | last post by:
I am trying to program a function to return a 2 dimensional array, but it's not working. I reduced the return value to 1 dimension and tested that to make sure that the problem wasn't elsewhere. ...
9
by: Luke Wu | last post by:
Hello, I'm having some problems understanding 2 dimensional arrays. My problem relates to the following code: #include <stdio.h> #define M 3 #define N 3
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
9
by: Dadi | last post by:
Hi, I can make a simple initialization work like this: Object ONE_ROW = {{"Vodafone", "5550160100197016"}}; But, now I want to create another array that consists of multiple copies of...
16
by: rguti | last post by:
Hi, How do I create a two dimensional array? I have created a one dimensional doing this: Dim laFields As ArrayList = New ArrayList How about to do a 2 dimensional?
5
by: Diffident | last post by:
Hello All, I have a 2-dimensional array that I am storing as a session variable. I have no idea on how I can cast the session variable back to 2-dimensional array. Any pointers? Reference...
4
by: entitledX | last post by:
Hi, I'm trying to use the HDF library to read a few HDF files that I need to process. The data in each file varies in rows, but the columns remain constant. Because of that, I had dynamically...
22
by: spam.noam | last post by:
Hello, I discovered that I needed a small change to the Python grammar. I would like to hear what you think about it. In two lines: Currently, the expression "x" is a syntax error. I suggest...
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
272
by: Peter Olcott | last post by:
http://groups.google.com/group/comp.lang.c++/msg/a9092f0f6c9bf13a I think that the operator() member function does not work correctly, does anyone else know how to make a template for making two...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.