Dynamically create Arrays to iterate

var a = new Array(10);
a[0] // returns undefined
a.length // returns 10, because of reasons.

The following example will NOT put anything to the console, because creating an array with length initialization will create an empty array (new Array(5) is equal to [,,,,,]).

var repeat = function(times) {
    return Array.apply(null, new Array(times));
};

References