DEV Community

Cover image for JavaScript and Scope VI - Closures

JavaScript and Scope VI - Closures

Todd Chaffee on June 22, 2019

In JavaScript and Scope II we saw that function scope is not determined by where a function is run. Instead, it is determined by where a function i...
Collapse
 
karataev profile image
Eugene Karataev

Thanks for the great series explaining how scopes work in JS. I'm just curious what programming languages don't follow functions lexical scope pattern, but organize "containers" for variables differently?

Collapse
 
tchaffee profile image
Todd Chaffee

I haven't personally worked with languages that use dynamic scope instead of lexical scope, but I read that Perl allows dynamic scope. Dynamic scope is harder to reason about because it relies on how the program runs instead of how the program is written.

Collapse
 
tchaffee profile image
Todd Chaffee

I will be happy to answer any questions about the article or about closures in general in the comments here.