# Context and Environment

### Execution Context:

* When java script engine sees the brackets, creates its own execution context inside the call stack, after the execution it will popes out the call stack.&#x20;
* Any time running the java scrip code, it will be a part of execution context.

![Execution Context Operation](https://2037876129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdbqCujxzeJqeQqlbM2%2F-LiJZ1_pPsHjSVseZhpY%2F-LiJdKqGwOWoXSiLMxmV%2Fimage.png?alt=media\&token=3eccc221-b7fe-4bea-9b7b-194e2e04186c)

#### &#x20;  Global Execution context:

* when ever we run the java script code, it creates a Global execution context that gives global object 'window' and 'this' and this === window.
* After the global execution context is created, functional execution context will be created.

### Lexical Environment:

* Lexical is compile time.
* Makes to know where the code is written.
* Every function creates a new lexical environment.
* Execution context says which lexical environment is currently running.

#### &#x20;   Lexical scope: (definition)

&#x20;   Lexical scope (available data + variables, where the function was defined) determines the available                                                     variables.

#### &#x20;  Dynamic scope: (execution)

&#x20;   Where the function is called.

![Execution Context](https://2037876129-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LdbqCujxzeJqeQqlbM2%2F-LkRTQkRwMHGMfegnsCO%2F-LkRXWyYqTIFlWgCs8uM%2Fimage.png?alt=media\&token=54d963a3-81c6-42dd-bd07-c482a62902de)
