Ways to iterate over undefined in Arrays

Is there any way to iterate over the holed arrays?

Majority (all?) built-in Array.prototype functions skip holes in sparse arrays.

That means that if you want to get the undefined value for the missing indexes - you need to turn that array into a non-sparse array first.

With the help of ES2015 you may use array iterators. The shortest way of doing it would be to use array spread syntax:

[...array]

Then you may apply a mapping operator to it [...array].map(handler)

I suspect that the exact bytes of these are actually different, and this strange behavior is due to how JavaScript displays these values which are not defined, not undefined. Am I correct? Is there any underlying explanation for this anomaly?

You are correct, it does not hold the undefined values explicitly. As arrays in JS are actually so called "intrinsic objects" (or shorter - just objects), their indexes are simply the properties of those objects. So when you skip an index - that property is simply not set and does not exist.

It is the same as if you access a non existing object property:

var o = {};
o.foo // undefined