When running this code I expect this to log 5 undefined's. However I only see two. It appears that JavaScript only logs undefined's that you define yourself. 
var a = [];
a[0]=undefined;
a[4]=undefined;
a.forEach((i)=>console.log(i))
This logs:
undefined
undefined
Wouldn't you expect it to log 4 undefined's?
Here is a codepen.
 
     
     
    