JavaScript

Lexical vs. dynamic scoping

In this blog I want to give you some examples about the difference between lexical and dynamic scoping. I will not dive into the details. You will find a lot of other resources about it. Here is a small list: Scope (computer science) Javascript — Lexical and Dynamic Scoping? What is lexical scope? The following JavaScript and Bash examples are almost equivalent in structure. Nevertheless they will lead to different results, because of the different scoping type these languages use. Lexical scoping – e.g. JavaScript In languages with lexical scope (also called static scope), name resolution depends on the location in the source code and the lexical context (also called static context), which is defined by… Read More »Lexical vs. dynamic scoping