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.
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] + ".");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With