Turning Learners Into Developers
Codekilla
CODEKILLA
back to course
Lesson 89 / 11577%
Advanced Concepts1/7

JS Closures

A function that 'remembers' variables from the scope it was created in.

// closure · inner function keeps a LIVE reference to its outer scopeouter() — scopelet count = 0;function inner() {count++;return count;}returncaller()const c = outer();c(); // 1c(); // 2c(); // 3Click a step to walk through the closure.
Visual explanation diagram · click steps to walk through it

This lesson is Pro only.

Unlock every premium lesson and module — Pro from ₹299 / month (or ₹999 / year, saves ~₹2,589).

Sign in to unlock
// feedback.matters()
Did this lesson help you?