-1

I need to access the variables inside this array in javascript, i need to be able to change the values of this variables in the code.

var imageLocations = {
    album : [ 0, 0, 0, 0, "images/woodstock1970.png" ],
    family : [ 0, 0, 0, 0, "images/manuelsilva.png" ],
    wedding : [ 0, 0, 0, 0, "images/wedding.png" ],
    travels : [ 0, 0, 0, 0, "images/benidorm1984.png" ]
};

i have a for each in the code and for each iteration of the loop i want to be able to change the 0's to other values.

Here is a more concrete example where i have the actual loop and what i am trying to do.

for ( var img in imageLocations) {
     imageLocations[img].???? = something;
}

what would i put in the ??? if i want to replace one of the 0's inside of every index of the imagelocations.

Amit Joki
  • 58,320
  • 7
  • 77
  • 95

1 Answers1

1

For your example, you'd want to do it like this:

for ( var img in imageLocations) {
  imageLocations[img][0] = something;
}
Robert Messerle
  • 3,022
  • 14
  • 18