Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
126
rated 0 times [  129] [ 3]  / answers: 1 / hits: 17216  / 15 Years ago, sat, may 23, 2009, 12:00:00

I am fairly new to JavaScript and I want to create objects and arrays using JavaScript.



What I'm basically after is a way of creating an object that will store the following information, i.e.:



[index, name] such as [0,NameA][1,NameB] etc.



I am unsure how to create an object/array to store this type of info with jQuery.



Secondly, I then need a means of passing this object/array as a parameter into another function then be able to loop through this object/array and print out it's contents.



Again, I am unsure how to do this part as well.


More From » arrays

 Answers
13

If you're interested in saving some data in an array, and pluck it out together with its index, why not do it the simplest way possible?



var arr = [Alpha, Bravo, Charlie, Dog, Easy];

for (i = 0; i<5; i++) {
alert(Element with index + i + is + arr[i] + .);
}

[#99470] Wednesday, May 20, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parker

Total Points: 259
Total Questions: 109
Total Answers: 97

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;