← JavaScript for Real
Lesson 2 · zap JavaScript for Real
Functions & Closures
Use closures deliberately instead of being surprised by them.
Before you start
A function remembers the scope it was created in, even after that scope has finished running. That's a closure. It's the mechanism behind private state, memoization, event handlers, and React hooks — and behind the classic loop-variable bug.
5 exercises·up to 85 XP·5/5 hearts