What does console.log([3, , 5].map(x => x ?? 0)); output?
A past puzzle — fully playable. 4 attempts, hints on wrong guesses.
stdle-89.js
1console.log([3,,5].map(x=>x??0));
Quirks
Answer & explanation
Console output
[ 3, <1 empty item>, 5 ]
Why
You might expect the hole to become 0 via x ?? 0, but map never invokes the callback for holes. It copies them straight into the result. So the missing slot is preserved as a hole rather than replaced, and the output keeps its <1 empty item>. To fill holes first, use fill or spread the array into a dense one.