Index of array in for-each loop

This is a question spawned from my previous post (you don’t have to read it):

Consider an array with x number of elements (of type Object) where some of the elements might be undefined.
I’d like to use a for-each loop to access all the elements of the array that is not undefined (since it simply skips the undefined elements).
But. I also want the index of that particular element.
So I have two options:

  1. Use array.indexOf(element).
  2. Use traditional for loop, thus getting the index out of the iterator.

I’d rather not use option 2 since it contradicts the whole idea of not having to deal with undefined elements.
But I’m wondering if option 1 will be quick enough, a feels a bit like looking for water on the other side of the river so to speak.

Can you think of other solutions?

:: nook