January 2020
Intermediate to advanced
548 pages
13h 36m
English
Inner scopes, as we've seen, have access to the variables of outer scopes:
function outer() { let thing = 123; function inner() { // I can access `thing` within here! thing; // => 123 } inner();}outer();
What naturally follows from this is the concept of a closure. A closure is how JavaScript enables you to continue to access the scope of an inner function regardless of where or when it is called.
Consider the following function (fn), which returns another function. It has its own ...
Read now
Unlock full access