You write Array(3).map((_, i) => i) to quickly render three loading skeletons—and the screen stays blank. The console shows no errors, length is 3, yet the callback never ran once.
The culprit is a sparse array. Calling Array(3) sets the length without creating numeric keys '0', '1', and '2'. You get empty slots, which behave differently from real undefined values: 0 in Array(3) returns false.
// Sparse array: length is 3, but no keys exist
const sparse = Array(3).map((_, i) => i);
// Spread uses the iterator, filling slots with undefined
const dense = [...Array(3)].map((_, i) => i);
// Cleaner: no intermediate array needed
const clean = Array.from({ length: 3 }, (_, i) => i);
console.log(Object.keys(sparse).length); // 0
console.log(Object.keys(dense).length); // 3
Per the ECMAScript specification, Array.prototype.map() checks whether each index exists via HasProperty before calling your function. No key means the step is skipped, leaving a hole in the new array. forEach, filter, and reduce behave the exact same way.
The [...] spread operator walks the array through its iterator, which yields real undefined values instead of holes so map() visits all three slots. Even simpler, use Array.from({ length: 3 }, (_, i) => i) with its built-in mapping callback.
