← Back to archive

Stdle #80 · scope · 2026-08-19

What does this JavaScript snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

var fns = [];
for (var i = 0; i < 3; i++) { fns.push(() => i); }
console.log(fns.map(f => f()).join(","));
Scope
4 attempts left

Answer & explanation