2

What's the difference between Lexical Environment and the Global Environment ?

from what i've seen the lexical environment contain environment record and outer reference to the outer lexical environment if that so.

if the outer reference has a reference to the parent lexical environment so that's mean that the Global Environment is also a lexical environment does it ? because if i call a function that was declared inside the Global Environment.

the outer reference should be a lexical environment so that's mean the Global Environment is a lexical environment.

AngryJohn
  • 576
  • 4
  • 10
  • Check out this link to see if it helps [Variable Environment vs lexical environment](https://stackoverflow.com/questions/23948198/variable-environment-vs-lexical-environment) – Ridwan Ajibola Sep 27 '21 at 21:12

1 Answers1

0

The reference is to outer lexical environment not a lexical environment itself.

Outer lexical environment == parent's Lexical environment

Global execution context (GEC) is not a lexical environment. But it also has a lexical environment having a reference to outer environment which points to null since it's parent is not possible.

  • I'd argue that the **Global Environment** is just the name we give to the lexical environment which is part of the global execution context. Of course the context itself is more than just the environment (scope) because it also includes bindings (ie. `this`) etc. – slebetman Jun 24 '22 at 03:46
  • Yes you are absolutely correct. I assumed that @AngryJohn is considering GEC as global environment. – coding-spidy Jun 24 '22 at 12:19