# 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](/files/-LiJdKqGwOWoXSiLMxmV)

#### &#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](/files/-LkRXWyYqTIFlWgCs8uM)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascript-1.gitbook.io/javascript/context-and-environment.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
