What does console.log(Array(3).fill(0).map((_, i) => i)); output?
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-24.js
1console.log(Array(3).fill(0).map((_,i)=>i));
Quirks
Answer & explanation
Console output
[ 0, 1, 2 ]
Why
Array(3) alone is sparse and map would skip its empty slots, but fill(0) writes a real value into each slot, turning them into actual elements. Now map iterates over all three indices and returns their positions, giving [0, 1, 2]. This fill-then-map pattern is the standard way to build a populated range.