CJCoding With Joseph
← Back to Question List
JavaScript Code Walkthrough #9

Closures Capturing let

hardFunctions

📄 Code

Read carefully — what does this print?
1const fns = [];
2for (let i = 0; i < 3; i++) {
3 fns.push(() => i);
4}
5console.log(fns.map((f) => f()).join(","));

🎯 Your Answer