DEV Community

Discussion on: What is Closure Scope?

Collapse
jsforlife profile image
jsforlife • Edited on

Excellent explanation.

Just need to add that internally closures maintain a seperate memory allocation of its lexical environment that is why when closure returned function is returned.
it looks to allocated memory for lookup process to find variable that was enclosed at the time of closure. I hope my understanding is correct ;)

Collapse
mariokandut profile image
Mario Author

Yes, exactly. Well explained. :) The inner function has there own lexical or static scope, and in the lookup process it looks first in the "own" memory.