DEV Community

Understanding Javascript Closures

Yamin on December 12, 2018

It was really a hard concept to understand and it took me a while to comprehend what closures are. So here is my understanding of what it is with...
Collapse
 
casperns profile image
Zelimir Stefanovic

Nice post and how I look at Closures:

When the main function is executed and some variables are assigned a return function,
even later by calling the returned function, we can access the variables that was in the call when the return function returned.

After the execution of the main function, the Scope chain is kept and referred to and is considered to be the parent of the function that is returned and which will be later called.

Collapse
 
abraham profile image
Abraham Williams

Small sidenote, if you label code snippets, they will look 🔥.

Collapse
 
yaminmhd profile image
Yamin

Oh wow! Cool! Thanks for the advise 🚀