-2

within the console.log I am receiving an array{items: Array(1)}

items: Array(1)
0: {id: 4, imageIndex: 3}
length: 1
__proto__: Array(0)
__proto__: Object

I am trying to print through this array to retrieve the imageIndex and getting an undefined.

for (var image in imageList) {
    console.log(image.imageIndex);
}

If I use for...of within the loop, I get an 'imageList' is not iterable.

drai29
  • 141
  • 1
  • 3
  • 19
  • IF you use for in , it gives you the index, then you might have to access it as item[i].imageIndex – Geeky Nov 17 '18 at 01:16

1 Answers1

3

Try for of

check this snippet

const arr =[{id: 4, imageIndex: 3}]
for (var item of arr) {
console.log(item.imageIndex);
}
Geeky
  • 7,420
  • 2
  • 24
  • 50