Tag: Lexical Scope

  • Lexical Scoping (or Static Scoping) Vs Dynamic Scoping

    Static (or lexical) scoping and dynamic scoping are two different ways that programming languages determine the scope of a variable. JavaScript uses lexical scoping. Lexical Scoping (Static Scoping): Example in JavaScript: Dynamic Scoping: Example (hypothetical) dynamic scoping behavior: In summary, JavaScript employs lexical scoping, where the scope of a variable is determined by its location…